https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121870
Bug ID: 121870
Summary: ICE when two calls to noreturn function via function
pointer in global variable
Product: gcc
Version: 15.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mnowak at kplabs dot pl
Target Milestone: ---
Created attachment 62351
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62351&action=edit
main1.cpp
Description:
Two calls two noreturn function (my own function, exit or std::terminate - does
not matter) via function pointer in global variable results in internal
compiler error: segmentation fault when built with LTO and O3.
Code that initially triggered this issue is much more conditional instead of
obvious [[noreturn]] calls and depends on external data input, still got ICE.
It seems that this issue is reproducible on many different architectures and
versions, checked via godbolt.org: https://godbolt.org/z/KecMoa18x (x66-64
trunk, AMD64 13.2.0 and PowerPC 11.2.0) - three randomly choosen
version/architectures and failed.
Exact version of GCC:
gcc version 15.1.1 20250425 (GCC) by ArchLinux
System type:
Arch Linux AMD64 VM on Hyper-V on Windows11
Options given when GCC was configured/built:
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
(retrieved from g++ -v output)
Command line:
g++ -flto -O3 ./main1.cpp
Compiler output:
during GIMPLE pass: ccp
./main1.cpp: In function ‘main’:
./main1.cpp:21:5: internal compiler error: Segmentation fault
21 | int main()
| ^
0x22e9d61 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x22ea590 internal_error(char const*, ...)
???:0
0xd95c27 fixup_noreturn_call(gimple*)
???:0
0xf3a40e substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See
<https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues> for
instructions.
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Source file:
Attached main1.cpp, no headers included