https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121390

            Bug ID: 121390
           Summary: ICE (Segmentation fault) when lambda parameter uses
                    anonymous struct type defined in parameter list
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jirehguo at tju dot edu.cn
  Target Milestone: ---

Here is the repro: https://godbolt.org/z/fb9zKb5qn
Trunk g++ crashes with a segmentation fault when compiling the following
invalid C++ code. This crash was introduced as a regression in GCC 6.1 and
affects all subsequent versions.

Code:
---
int main() {
  struct {
    char field1[8];
  } * structPtr;
  auto dumpMethod = [](const struct { char field1[8]; } *s) {};
  dumpMethod(structPtr);
  return 0;
}


The compiler produces the expected error message but then crashes with a
segmentation fault:
---
<source>: In function 'int main()':
<source>:5:37: error: types may not be defined in parameter types
    5 |   auto dumpMethod = [](const struct { char field1[8]; } *s) {};
      |                                     ^
g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 4

Reply via email to