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

            Bug ID: 125679
           Summary: [C++] ICE: Segmentation fault during error recovery
                    when a struct is defined in a lambda parameter list
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 1794833681 at qq dot com
  Target Milestone: ---

The C++ frontend correctly diagnoses an invalid struct definition within a
lambda parameter list (`error: types may not be defined in parameter types`).
However, it fails to recover gracefully, resulting in a Segmentation fault in
`cc1plus` during subsequent processing (possibly related to auto return type
deduction or the variadic arguments `...`).

**Minimal Reproducible Example:**
class SystemManager {
private:
    auto internal_method() {
        return [](struct State {int current; int previous;}status, ...) {
        };
    }
public:
    void run() {
        auto handler = internal_method();
    }
};

int main() {
    SystemManager manager;
    manager.run();
    return 0;
}

**Command Line Arguments:**
g++ -std=c++23 source.cpp

**Tested Versions:**
* Reproduced on: x86-64 gcc 15.1 15.2
* Reproduced on: x86-64 gcc 16.1

**Compiler Output:**
<source>: In member function 'auto SystemManager::internal_method()':
<source>:4:32: error: types may not be defined in parameter types
    4 |                 return [](struct State {int current; int
previous;}status, ...) {
      |                                ^
g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report, with preprocessed source (by using
-freport-bug).

**Expected Behavior:**
The compiler should emit the syntax error `types may not be defined in
parameter types` and halt compilation or gracefully recover the AST, rather
than crashing with an ICE (Segmentation fault).

Reply via email to