[Bug c++/126759] New: ICE in tsubst_expr, at cp/pt.cc:22938

gcc at maxmitti dot at via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126759

            Bug ID: 126759
           Summary: ICE in tsubst_expr, at cp/pt.cc:22938
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at maxmitti dot at
  Target Milestone: ---

Created attachment 65283
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65283&action=edit
Preprocesesd soure code

The following code produces an ICE:

template <int v>
struct c{};

template <typename T>
concept a = requires (T v) { c<v>{}; };

template <typename T>
concept b = requires (T w) { c<w>{}; };

void foo()
{
        b<int>;
}



With the following output:

$ g++ -save-temps -v test.cpp

g built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/16/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../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-gcc-major-version-only
--with-linker-hash-style=gnu --with-system-zlib --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-fixincludes --disable-libssp
--disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.1.1 20260728 (GCC) 
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64' '-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-pc-linux-gnu/16/cc1plus -E -quiet -v -D_GNU_SOURCE
test.cpp -mtune=generic -march=x86-64 -fpch-preprocess -o a-test.ii
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/16/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../include/c++/16

/usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../include/c++/16/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../include/c++/16/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/16/include
 /usr/local/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64' '-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-pc-linux-gnu/16/cc1plus -fpreprocessed a-test.ii -quiet
-dumpdir a- -dumpbase test.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64
-version -o a-test.s
GNU C++20 (GCC) version 16.1.1 20260728 (x86_64-pc-linux-gnu)
        compiled by GNU C version 16.1.1 20260728, GMP version 6.3.0, MPFR
version 4.2.2, MPC version 1.4.1, isl version isl-0.28-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 92a285fc5382abf8eb3acadb63c2d94b
test.cpp: In function ‘void foo()’:
test.cpp:8:30: internal compiler error: in tsubst_expr, at cp/pt.cc:22935
    8 | concept b = requires (T w) { c<w>{}; };
      |                              ^~~~~~
0x2815a98 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x28180a7 internal_error(char const*, ...)
        ???:0
0x737a7f fancy_abort(char const*, int, char const*)
        ???:0
0x964f71 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x970a47 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x976671 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x7b9b73 evaluate_concept_check(tree_node*)
        ???:0
0x7ce227 convert_to_void(tree_node*, impl_conv_void, int)
        ???:0
0x9cb8be finish_expr_stmt(tree_node*)
        ???:0
0xaa51c0 c_common_parse_file()
        ???:0
/usr/lib/gcc/x86_64-pc-linux-gnu/16/cc1plus -fpreprocessed a-test.ii -quiet
-dumpdir a- -dumpbase test.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64
-version -o a-test.s
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.



Multiple versions are affected: 14.3, 14.4, 15.1, 15.2, 15.3, 16.1, 16.2 and
trunk
All tested on godbolt.org: https://godbolt.org/z/hEEdjj163
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.