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

            Bug ID: 127520
           Summary: ICE on valid code
           Product: gcc
           Version: 14.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.weisser.m at gmail dot com
  Target Milestone: ---

Created attachment 65644
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65644&action=edit
Self-contained translation unit that reproduces the crash

## Summary

g++ 14.4.0 crashes with an internal compiler error (segmentation fault) when
compiling code that instantiates googletest's parameterized-test machinery
(`::testing::Values(...)` / `::testing::ValuesIn(...)`) with `std::string` as
the parameter type. The crash happens in the front end while instantiating a
`static_cast` between two class template specializations, inside
`comp_type_attributes`.

This reproduces only when targeting **aarch64-linux-gnu**; the identical
source compiles cleanly with the same compiler build (same configure options,
same GCC 14.4.0 sources) targeting **x86_64-linux-gnu**. It is independent of
optimization level, `-g`, and warning flags.

## Command line

aarch64-gs-linux-gnu-g++ --sysroot=<aarch64-sysroot-with-glibc-and-libstdc++> \
  -std=gnu++17 -c repro.cc -o repro.o

## Reduced testcase

Requires only a system-installed googletest (`gtest/gtest.h`)

#include <gtest/gtest.h>

class P : public ::testing::TestWithParam<std::string> {};
TEST_P(P, Works) { SUCCEED(); }
INSTANTIATE_TEST_SUITE_P(X, P, ::testing::Values("a", "b"));
```

A preprocessed, self-contained translation unit that reproduces the crash
without needing gtest installed is attached (`gtest_param_string_ice.ii.gz`,
generated with `-E` from the above, ~88k lines due to STL/libstdc++ headers).

## Environment

```
$ aarch64-gs-linux-gnu-g++ -v
Using built-in specs.
COLLECT_GCC=aarch64-gs-linux-gnu-gcc
Target: aarch64-gs-linux-gnu
Configured with: .../configure --build=x86_64-build_pc-linux-gnu \
  --host=x86_64-build_pc-linux-gnu --target=aarch64-gs-linux-gnu \
  --prefix=... --exec_prefix=...
--with-sysroot=.../aarch64-gs-linux-gnu/sysroot \
  --enable-languages=c,c++ --with-pkgversion='crosstool-NG 1.28.0.58_27cd838' \
  --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp
\
  --disable-libquadmath --disable-libquadmath-support --enable-libsanitizer \
  --disable-libmpx --with-gmp=... --with-mpfr=... --with-mpc=... --with-isl=...
\
  --enable-lto --enable-threads=posix --disable-libstdcxx-pch --enable-plugin \
  --with-libintl-prefix=... --disable-multilib \
  --with-local-prefix=.../aarch64-gs-linux-gnu/sysroot --enable-long-long
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.4.0 (crosstool-NG 1.28.0.58_27cd838)
```

Host: x86_64-pc-linux-gnu (Ubuntu, Linux 6.8.0), toolchain built via
crosstool-NG 1.28.0.58.
  • [Bug c++/127520] New: ICE on val... m.weisser.m at gmail dot com via Gcc-bugs

Reply via email to