Bug 57416 - internal compiler error: in gimple_expand_cfg, at cfgexpand.c:4575
Summary: internal compiler error: in gimple_expand_cfg, at cfgexpand.c:4575
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2013-05-25 17:02 UTC by Frank Bergemann
Modified: 2013-08-12 22:55 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test program main.cpp compiled in eclipse with -std=c++11 (356 bytes, text/x-c++src)
2013-05-25 17:02 UTC, Frank Bergemann
Details
fixed version of test program - compilation works now (374 bytes, text/x-c++src)
2013-05-25 18:18 UTC, Frank Bergemann
Details
fixed version of test program - compilation works now (367 bytes, text/x-c++src)
2013-05-25 18:24 UTC, Frank Bergemann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Bergemann 2013-05-25 17:02:28 UTC
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 ****
Comment 1 Daniel Krügler 2013-05-25 17:59:06 UTC
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."
Comment 2 Frank Bergemann 2013-05-25 18:18:23 UTC
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
Comment 3 Frank Bergemann 2013-05-25 18:24:30 UTC
Created attachment 30195 [details]
fixed version of test program - compilation works now

missed to fix another location of invalid code - sorry
\Frank
Comment 4 Daniel Krügler 2013-05-25 18:26:28 UTC
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?
Comment 5 Daniel Krügler 2013-05-25 18:27:29 UTC
(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.
Comment 6 Frank Bergemann 2013-05-25 19:55:01 UTC
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 ****
Comment 7 Richard Biener 2013-05-27 08:27:28 UTC
Testcase still ICEs on the branch, errors on trunk.
Comment 8 Paolo Carlini 2013-08-12 22:53:07 UTC
The ICE is indeed fixed in mainline. I'm going to commit a (reduced) testcase and close the issue.
Comment 9 Paolo Carlini 2013-08-12 22:55:51 UTC
Done.