https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126206
Bug ID: 126206
Summary: ICE when an undeclared name is used and a header unit
that defines that name is imported later in the same
translation unit
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: drew.dormann at gmail dot com
Target Milestone: ---
## Minimal reproducer (standard library only)
Build the `<cstdio>` header unit
```console
$ g++ -std=c++26 -fmodules -fmodule-header=system -x c++-system-header cstdio
```
Then compile the following (assuming filename repro.cpp):
```c++
void* p = stdin; // 'stdin' undeclared at this point
import <cstdio>; // header unit DEFINES stdin, imported AFTER the use
int main() {}
```
```console
$ g++ -std=c++26 -fmodules -c repro.cpp
repro.cpp:1:11: internal compiler error: Segmentation fault
```