- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to make a few read-only variables, at file-scope. A couple of them are dependent on other such variables. A sample code is as follows:
static const double A = 1.0;
static const double B = A/5;
int main(){}
Compiling this gives me the error:
expression must have a constant value
But GCC does not complain. Is this a bug in ICC, or is it GCC that isn't standard compliant?
Is this relevant: ?
https://software.intel.com/en-us/forums/intel-c-compiler/topic/286645
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've tried GCC 4.8.3, 6.3.0 and 7.3.0. They all gave an error as seen below:
vahoang@orcsle147:/tmp$ gcc t.c -c
t.c:3:25: error: initializer element is not constant
static const double B = A/5;
^
vahoang@orcsle147:/tmp$ cat t.c
#include<stdio.h>
static const double A = 1.0;
static const double B = A/5;
int main(){}
vahoang@orcsle147:/tmp$ icc t.c -c
t.c(3): error: expression must have a constant value
static const double B = A/5;
^
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Viet Hoang (Intel) wrote:I'm using GCC 8.2.1
I've tried GCC 4.8.3, 6.3.0 and 7.3.0. They all gave an error as seen below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The test passed when compile with -Tp
tmp$ icpc -Tp t.c -c
tmp$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's a workaround. I've filed an internal bug against ICC. The tracker number is: CMPLRIL0-30632
Thanks,
Viet

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page