Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

assertion failed on in class member initialization

Bert_Jonson
Beginner
737 Views

[cpp]static const int x = 10;

struct S {
int a = x;
};

int main() {
S s;
}[/cpp]

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?

0 Kudos
6 Replies
Feilong_H_Intel
Employee
737 Views
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
0 Kudos
Bert_Jonson
Beginner
737 Views
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)
0 Kudos
Judith_W_Intel
Employee
737 Views
Thank you for reporting this. I have entered this into our bug tracking system as DPD200239790. Judy
0 Kudos
SergeyKostrov
Valued Contributor II
737 Views
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.
0 Kudos
SergeyKostrov
Valued Contributor II
737 Views
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 ...
0 Kudos
Feilong_H_Intel
Employee
737 Views

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

Feilong

0 Kudos
Reply