Bug 84576 - [11/12/13/14 Regression] g++: internal compiler error: Segmentation fault (program cc1plus)
Summary: [11/12/13/14 Regression] g++: internal compiler error: Segmentation fault (pr...
Status: RESOLVED DUPLICATE of bug 56260
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.3.0
: P4 normal
Target Milestone: 11.5
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-02-26 19:03 UTC by Vegard Nossum
Modified: 2024-03-07 16:50 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vegard Nossum 2018-02-26 19:03:05 UTC
The following is obviously not a valid C++ program but crashes the compiler:

a(){[](class{

Output:

<source>:1:3: error: ISO C++ forbids declaration of 'a' with no type [-fpermissive]
 a(){[](class{
   ^
<source>: In function 'int a()':
<source>:1:13: error: types may not be defined in parameter types
 a(){[](class{
             ^
<source>:1:13: error: expected '}' at end of input
<source>:1:13: error: expected ',' or '...' at end of input
<source>:1:13: error: expected ')' at end of input
g++: internal compiler error: Segmentation fault (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 4

I used C-Reduce on a bigger program to find a smaller test case.
Comment 1 Marek Polacek 2018-02-26 19:20:54 UTC
Confirmed.
Comment 2 Jakub Jelinek 2018-02-27 11:41:29 UTC
Started to ICE in between r152207 and r152360, seems endless recursion in dump_* while trying to print some diagnostics.
Comment 3 Jakub Jelinek 2018-02-27 11:43:47 UTC
BTW, when using creduce, if the original is valid or has just one error or something similar, please try to write the script such that it will not confirm a reduction which has also other errors, otherwise you end up with testcases like this which have just too many errors in it.
Comment 4 Vegard Nossum 2018-02-27 11:56:30 UTC
(In reply to Jakub Jelinek from comment #3)
> BTW, when using creduce, if the original is valid or has just one error or
> something similar, please try to write the script such that it will not
> confirm a reduction which has also other errors, otherwise you end up with
> testcases like this which have just too many errors in it.

Thanks, I will try to do this in the future. I believe the original had only one error.
Comment 5 Vegard Nossum 2018-02-28 09:48:06 UTC
I have another testcase which crashes in a similar way, but I'm not sure if it's the same underlying bug or not:

void a() {
  enum * {
    [] (union {})
  };
}

The original crash was:

(gdb) run
Starting program: xgcc -x c++ -std=c++14 -O3 -Wall -fpermissive -c input-1.cc
[New process 19395]
process 19395 is executing new program: cc1plus
input-1.cc:1:3: warning: ISO C++ forbids declaration of 'a' with no type [-fpermissive]
 a(){[](class{
   ^
input-1.cc: In function 'int a()':
input-1.cc:1:13: error: types may not be defined in parameter types
 a(){[](class{
             ^
input-1.cc:1:13: error: expected '}' at end of input
input-1.cc:1:13: error: expected ',' or '...' at end of input
input-1.cc:1:14: error: expected ')' at end of input
 a(){[](class{
       ~     ~^
              )

Thread 2.1 "cc1plus" received signal SIGSEGV, Segmentation fault.
[Switching to process 19395]
0x000000000167a1f4 in ggc_internal_alloc (size=48, f=0x0, s=0, n=1) at /home/vegard/git/gcc/gcc/ggc-page.c:1274
1274      entry = G.pages[order];
(gdb) bt
#0  0x000000000167a1f4 in ggc_internal_alloc (size=48, f=0x0, s=0, n=1) at /home/vegard/git/gcc/gcc/ggc-page.c:1274
#1  0x0000000000000000 in ?? ()

The new one is:

(gdb) run
Starting program: xgcc -x c++ -std=c++14 -O3 -Wall -fpermissive -c input.cc
[New process 14133]
process 14133 is executing new program: cc1plus
input.cc: In function 'void a()':
input.cc:3:15: error: types may not be defined in parameter types
     [] (union {})
               ^

Thread 2.1 "cc1plus" received signal SIGSEGV, Segmentation fault.
[Switching to process 14133]
0x00000000010529cd in dguide_name_p (name=0x7ffff6d5c000) at /home/vegard/git/gcc/gcc/cp/pt.c:25423
25423   {
(gdb) bt
#0  0x00000000010529cd in dguide_name_p (name=0x7ffff6d5c000) at /home/vegard/git/gcc/gcc/cp/pt.c:25423
#1  0x0000000000000000 in ?? ()

It crashes in a different place but they both have the "types may not be defined in parameter types" error and I'm not sure why gdb is not able to follow the stack properly.
Comment 6 Jakub Jelinek 2018-10-26 10:23:37 UTC
GCC 6 branch is being closed
Comment 7 Richard Biener 2019-11-14 07:53:12 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 8 Jakub Jelinek 2020-03-04 09:46:40 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 9 Jakub Jelinek 2021-05-14 09:50:02 UTC
GCC 8 branch is being closed.
Comment 10 Richard Biener 2021-06-01 08:10:27 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 11 Richard Biener 2022-05-27 09:38:29 UTC
GCC 9 branch is being closed
Comment 12 Jakub Jelinek 2022-06-28 10:34:38 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 13 Richard Biener 2023-07-07 10:33:22 UTC
GCC 10 branch is being closed.
Comment 14 Andrew Pinski 2024-03-07 16:50:03 UTC
Dup of bug 56260.

*** This bug has been marked as a duplicate of bug 56260 ***