Created attachment 30193 [details] test program main.cpp compiled in eclipse with -std=c++11 while experimenting with http://www.drdobbs.com/cpp/access-data-items-in-ancestor-stack-fram/240155450 i got this error here: **** Build of configuration Debug for project RetainRecall **** make all Building file: ../main.cpp Invoking: GCC C++ Compiler /opt/gcc-4.8.0/bin/g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" ../main.cpp: In constructor ‘constexpr func1(PARENTDATA&) [with PARENTDATA = Nothing]::Data::Data()’: ../main.cpp:43:9: internal compiler error: in gimple_expand_cfg, at cfgexpand.c:4575 struct Data ^ 0x655603 gimple_expand_cfg ../../gcc/cfgexpand.c:4575 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. make: *** [main.o] Error 1 **** Build Finished ****
In the gcc 4.9.0 trunk I see no ICE, only a compiler error. Of-course ICEs need to be fixed, but I think the example code is notvalid C++11, because the initialization of the member of the local classes Data odr-use the function parameter p_parent_data according to 9.8 p1: "[..] Declarations in a local class shall not odr-use (3.2) a variable with automatic storage duration from an enclosing scope."
Created attachment 30194 [details] fixed version of test program - compilation works now Hi Daniel, thanks for the hint! - i was not aware of this rule. Attached a new version of test program, which doesn't have this problem anymore. best regards, Frank
Created attachment 30195 [details] fixed version of test program - compilation works now missed to fix another location of invalid code - sorry \Frank
If you remove the still existing member initializer in func1, does the ICE still exist? (On 4.9 after removal of that initializer I could compile and run the program). Are all the compiler flags necessary to reproduce the ICE, or will e.g. the combination of -Wall -std=c++11 suffice to produce the ICE?
(In reply to Daniel Krügler from comment #4) We had a clash here, but except for my first observation the remaining questions are still relevant.
the error depends on optimization level. -O0 has the problem -O1, -02, -03 do not have the problem. For those i get - even for the original buggy code: make all Building file: ../main.cpp Invoking: GCC C++ Compiler /opt/gcc-4.8.0/bin/g++ -O1 -g3 -Wall -c -std=c++11 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" ../main.cpp: In function ‘void func3(PARENTDATA&) [with PARENTDATA = func2(PARENTDATA&) [with PARENTDATA = func1(PARENTDATA&) [with PARENTDATA = Nothing]::Data]::Data]’: ../main.cpp:23:47: warning: ‘p_parent_data’ may be used uninitialized in this function [-Wmaybe-uninitialized] std::cout << "parent_data.parent_data.x = " << data.parent_data.parent_data.x << std::endl; ^ ../main.cpp: In function ‘void func2(PARENTDATA&) [with PARENTDATA = func1(PARENTDATA&) [with PARENTDATA = Nothing]::Data]’: ../main.cpp:29:9: warning: ‘p_parent_data’ is used uninitialized in this function [-Wuninitialized] Finished building: ../main.cpp Building target: RetainRecallOld Invoking: GCC C++ Linker /opt/gcc-4.8.0/bin/g++ -o "RetainRecallOld" ./main.o struct Data ^ ../main.cpp: In function ‘void func1(PARENTDATA&) [with PARENTDATA = Nothing]’: ../main.cpp:43:9: warning: ‘p_parent_data’ is used uninitialized in this function [-Wuninitialized] struct Data ^ Finished building target: RetainRecallOld **** Build Finished ****
Testcase still ICEs on the branch, errors on trunk.
The ICE is indeed fixed in mainline. I'm going to commit a (reduced) testcase and close the issue.
Done.