Subject: gcc-11: ICE with LTO: internal compiler error: tree code ‘c_maybe_const_expr’ is not supported in LTO streams

From: Martin Uecker <[email-masked]>
Date: Sun, 21 Aug 2022 15:34:08 +0200

Package: gcc-11
Version: 11.3.0-5
Severity: important
Tags: upstream
X-Debbugs-Cc: [email-masked]

When investigating why BART fails to build with LTO because
GCC crashed, I reduced this to the following test case.

Upstream bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106702

$ cat test.c 

extern void bar(int M, int N, float S[(N > M) ? M : N]);

void foo(int M, int N)
{
	bar(M, N, 0);
}

$ gcc-11 -I ../src/  -flto test.c 
during IPA pass: modref
test.c:8:1: internal compiler error: tree code ‘c_maybe_const_expr’ is not supported in LTO streams
    8 | }
      | ^
0x7fa316e01209 __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7fa316e012bb __libc_start_main_impl
	../csu/libc-start.c:389
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.

-- System Information:
Debian Release: 11.4
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-16-amd64 (SMP w/16 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages gcc-11 depends on:
ii  binutils       2.38.90.20220713-2
ii  cpp-11         11.3.0-5
ii  gcc-11-base    11.3.0-5
ii  libc6          2.34-3
ii  libcc1-0       12.1.0-8
ii  libgcc-11-dev  11.3.0-5
ii  libgcc-s1      12.1.0-8
ii  libgmp10       2:6.2.1+dfsg1-1
ii  libisl23       0.23-1
ii  libmpc3        1.2.0-1
ii  libmpfr6       4.1.0-3
ii  libstdc++6     10.2.1-6
ii  libzstd1       1.5.2+dfsg-1
ii  zlib1g         1:1.2.11.dfsg-2+deb11u1

Versions of packages gcc-11 recommends:
ii  libc6-dev  2.34-3

Versions of packages gcc-11 suggests:
pn  gcc-11-doc       <none>
pn  gcc-11-locales   <none>
pn  gcc-11-multilib  <none>

-- no debconf information