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

            Bug ID: 123893
           Summary: Using std::printf after import std causes an ICE
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rubenperez038 at gmail dot com
  Target Milestone: ---

I hope this is the right place to submit this. I'm experimenting with g++
15.2.0 and import std and I've encountered an ICE. This is the program I'm
building:

```
import std;

int main()
{
    std::printf( "%d", 42 );
}
```

Errors with the following:

```
during GIMPLE pass: ealias
main.cpp: In function 'int printf(const char*, ...)':
main.cpp:2:39: internal compiler error: in nonnull_arg_p, at tree.cc:14759
    2 | int main() { std::printf( "%d", 42 ); }
      |                                       ^
0x16e03e3 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x16b3e5d internal_error(char const*, ...)
        ???:0
0x16b3f33 fancy_abort(char const*, int, char const*)
        ???:0
0x1814388 gimple_range_global(vrange&, tree_node*, function*)
        ???:0
0x18131a7 global_range_query::range_of_expr(vrange&, tree_node*, gimple*)
        ???:0
0x198db53 compute_may_aliases()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions.
root@ff3c516edd6c:/workspace/__build_gcc15/repro# g++ --version
g++ (Ubuntu 15.2.0-4ubuntu4) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

This is a self-contained script that reproduces the issue:

```
cat << 'EOF' > std.bmi.modmap
$root .
std std.bmi
EOF

cat << 'EOF' > main.cpp
import std;
int main() { std::printf( "%d", 42 ); }
EOF

g++ -DNDEBUG -O3 -std=gnu++23 -fmodules-ts -fmodule-only
-fmodule-mapper=std.bmi.modmap -o std.bmi -c /usr/include/c++/15/bits/std.cc
g++ -DNDEBUG -O3 -std=gnu++23 -fmodules-ts -fmodule-mapper=std.bmi.modmap -o
main main.cpp
```

I'm using the g++ and libstdc++ versions that get installed on Ubuntu 25.10
Docker container, to make it easier to reproduce. g++ is installed as per:

```
apt update && apt install g++-15
```

This does not happen without `-O3`.

Please let me know if you need something else to reproduce.

Cheers,
Ruben.
  • [Bug c++/123893] New: Using st... rubenperez038 at gmail dot com via Gcc-bugs

Reply via email to