assertion failed on in class member initialization

assertion failed on in class member initialization

static const int x = 10;
struct S {
 int a = x;
};
int main() {
 S s;
}

internal error: assertion failed at: "shared/cfe/edgcpfe/expr.c", line 39144

ICC 13 update 1 on windows.

And question: when about will be new release/beta of ICC?

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Bert,

I got the following error with icc 13 update 1. Please let me know the compiler options you were using.

>icl -c test.cpp
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Ve
rsion 13.0.1.119 Build 20121008
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.
icl: command line warning #10006: ignoring unknown option '/std=c99'

test.cpp
test.cpp(3): error: data member initializer is not allowed
int a = x;
^

compilation aborted for test.cpp (code 2)
>

Thanks,
Feilong

Hi, man! Only /Qstd=c++0x because it's c++11 feature.

J:\>icl /Qstd=c++0x main.cpp
Intel(R) C++ Compiler XE for applications running on IA-32, Version 13.0 Build 2
0121008
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.

main.cpp
main.cpp(3): internal error: assertion failed at: "shared/cfe/edgcpfe/expr.c", l
ine 39144

struct S {
^

compilation aborted for main.cpp (code 4)

Thank you for reporting this. I have entered this into our bug tracking system as DPD200239790.

Judy

I've done a quick verification with MS C/C++ compiler and it fails to compile the test case:

...
...error C2864: 'S::a' : only static const integral data members can be initialized within a class
...

I think Intel C++ compiler shoul display a regular compilation error.

And three more verifications with the test-case provided:

[ Borland C++ compiler ]
...
Error E2233 ../../Common/PrtTests.cpp 678: Cannot initialize a class member here
...

[ MinGW C++ compiler ]
...
../../Common/PrtTests.cpp:678: error: ISO C++ forbids initialization of member `a'
../../Common/PrtTests.cpp:678: error: making `a' static
../../Common/PrtTests.cpp:678: error: ISO C++ forbids in-class initialization of non-const static member `a'
...

[ Turbo C++ compiler ]
...
Error ../../Common/PrtTests.cpp 678: Cannot initialize a class member here
...

The internal error issue has been resolved in 14.0 compiler.  FYI.

Feilong

Login to leave a comment.