https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103631
Bug ID: 103631 Summary: Internal compiler error in C++20 class NTTP + concept Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: winmikedows at hotmail dot com Target Milestone: --- I am using GCC 11.2.0 on macOS 10.15.7, and it throw ICE on the following code snippet: ```cpp // value_specialize, work with NTTP only template<typename Target, template<auto> typename T> inline constexpr bool is_specialize_value_v = false; template<template<auto> typename T, auto Ts> inline constexpr bool is_specialize_value_v<T<Ts>, T> = true; template<typename Target, template<auto> typename T> concept specialize_value = is_specialize_value_v<Target, T>; template<int i> struct Test{}; template<Test str> struct A { template<typename T> requires specialize_value<T, A> int fun(T&&) { return 1; } }; ``` The full compiler output of my invocation `g++-11 -v -save-temps -O0 -std=c++20 -Wall -Wextra -o code code.cpp` is (The intermediate file code.ii is identical to code.cpp except some #-directives since I'm not using the preprocessor, and code.s is empty, so I will not include them) ``` Using built-in specs. COLLECT_GCC=g++-11 COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/11.2.0_3/libexec/gcc/x86_64-apple-darwin19/11/lto-wrapper Target: x86_64-apple-darwin19 Configured with: ../configure --prefix=/usr/local/Cellar/gcc/11.2.0_3 --libdir=/usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran,d --program-suffix=-11 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-zstd=/usr/local/opt/zstd --with-pkgversion='Homebrew GCC 11.2.0_3' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --enable-libphobos --build=x86_64-apple-darwin19 --with-system-zlib --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Homebrew GCC 11.2.0_3) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O0' '-std=c++20' '-Wall' '-Wextra' '-o' 'code' '-mmacosx-version-min=10.15.0' '-asm_macosx_version_min=10.15' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/11.2.0_3/libexec/gcc/x86_64-apple-darwin19/11/cc1plus -E -quiet -v -D__DYNAMIC__ code.cpp -fPIC -mmacosx-version-min=10.15.0 -mtune=core2 -std=c++20 -Wall -Wextra -O0 -fpch-preprocess -o code.ii ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/gcc/x86_64-apple-darwin19/11/../../../../../../x86_64-apple-darwin19/include" ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/gcc/x86_64-apple-darwin19/11/../../../../../../include/c++/11 /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/gcc/x86_64-apple-darwin19/11/../../../../../../include/c++/11/x86_64-apple-darwin19 /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/gcc/x86_64-apple-darwin19/11/../../../../../../include/c++/11/backward /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/gcc/x86_64-apple-darwin19/11/include /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/gcc/x86_64-apple-darwin19/11/include-fixed /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O0' '-std=c++20' '-Wall' '-Wextra' '-o' 'code' '-mmacosx-version-min=10.15.0' '-asm_macosx_version_min=10.15' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/11.2.0_3/libexec/gcc/x86_64-apple-darwin19/11/cc1plus -fpreprocessed code.ii -fPIC -quiet -dumpbase code.cpp -dumpbase-ext .cpp -mmacosx-version-min=10.15.0 -mtune=core2 -O0 -Wall -Wextra -std=c++20 -version -o code.s GNU C++20 (Homebrew GCC 11.2.0_3) version 11.2.0 (x86_64-apple-darwin19) compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++20 (Homebrew GCC 11.2.0_3) version 11.2.0 (x86_64-apple-darwin19) compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: c8ad714ab17745b5fe60039e428beb58 code.cpp:14:35: internal compiler error: in unify, at cp/pt.c:23587 14 | template<typename T> requires specialize_value<T, A> | ^~~~~~~~~~~~~~~~~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. See <https://github.com/Homebrew/homebrew-core/issues> for instructions. ``` I can also reproduce the behavior in godbolt on GCC trunk: https://godbolt.org/z/bxeYvdezP, and clang++ pass with the code, so I think this code is valid. BTW, I also tried altering the code, and found that if you do any one of the four things below, GCC will pass with it. 1. change line 6 to use `template<int>` instead of `template<auto>` 2. change line 9 to remove template and just use `struct Test{}` 3. change line 11 to use any other type of NTTP (like `int`) 4. change line 14 to use `is_specialize_value_v` instead of `specialize_value` So probably this ICE is just the result of code complexity.