From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 26D3E385800E; Thu, 9 Dec 2021 13:51:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26D3E385800E From: "winmikedows at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103631] New: Internal compiler error in C++20 class NTTP + concept Date: Thu, 09 Dec 2021 13:51:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: winmikedows at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Dec 2021 13:51:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103631 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 c= ode snippet: ```cpp // value_specialize, work with NTTP only template typename T> inline constexpr bool is_specialize_value_v =3D false; template typename T, auto Ts> inline constexpr bool is_specialize_value_v, T> =3D true; template typename T> concept specialize_value =3D is_specialize_value_v; template struct Test{}; template struct A { template requires specialize_value int fun(T&&) { return 1; } }; ``` The full compiler output of my invocation `g++-11 -v -save-temps -O0 -std= =3Dc++20 -Wall -Wextra -o code code.cpp` is (The intermediate file code.ii is identi= cal 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=3Dg++-11 COLLECT_LTO_WRAPPER=3D/usr/local/Cellar/gcc/11.2.0_3/libexec/gcc/x86_64-app= le-darwin19/11/lto-wrapper Target: x86_64-apple-darwin19 Configured with: ../configure --prefix=3D/usr/local/Cellar/gcc/11.2.0_3 --libdir=3D/usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11 --disable-nls --enable-checking=3Drelease --with-gcc-major-version-only --enable-languages=3Dc,c++,objc,obj-c++,fortran,d --program-suffix=3D-11 --with-gmp=3D/usr/local/opt/gmp --with-mpfr=3D/usr/local/opt/mpfr --with-mpc=3D/usr/local/opt/libmpc --with-isl=3D/usr/local/opt/isl --with-zstd=3D/usr/local/opt/zstd --with-pkgversion=3D'Homebrew GCC 11.2.0_= 3' --with-bugurl=3Dhttps://github.com/Homebrew/homebrew-core/issues --enable-libphobos --build=3Dx86_64-apple-darwin19 --with-system-zlib --disable-multilib --with-native-system-header-dir=3D/usr/include --with-sysroot=3D/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=3D'-v' '-save-temps' '-O0' '-std=3Dc++20' '-Wall' '-Wex= tra' '-o' 'code' '-mmacosx-version-min=3D10.15.0' '-asm_macosx_version_min=3D10.= 15' '-shared-libgcc' '-mtune=3Dcore2' /usr/local/Cellar/gcc/11.2.0_3/libexec/gcc/x86_64-apple-darwin19/11/cc1plu= s -E -quiet -v -D__DYNAMIC__ code.cpp -fPIC -mmacosx-version-min=3D10.15.0 -mtune=3Dcore2 -std=3Dc++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/Framework= s" #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/inc= lude /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/gcc/x86_64-apple-darwin19/11/incl= ude-fixed /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Fra= meworks End of search list. COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-O0' '-std=3Dc++20' '-Wall' '-Wex= tra' '-o' 'code' '-mmacosx-version-min=3D10.15.0' '-asm_macosx_version_min=3D10.= 15' '-shared-libgcc' '-mtune=3Dcore2' /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=3D10.15.0 -mtune=3Dcore2 -O0 -Wall -Wextra -std=3Dc++2= 0 -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=3D100 --param ggc-min-heapsize=3D131= 072 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=3D100 --param ggc-min-heapsize=3D131= 072 Compiler executable checksum: c8ad714ab17745b5fe60039e428beb58 code.cpp:14:35: internal compiler error: in unify, at cp/pt.c:23587 14 | template requires specialize_value | ^~~~~~~~~~~~~~~~~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. See 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` instead of `template` 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_val= ue` So probably this ICE is just the result of code complexity.=