[Bug c++/112633] [13/14 Regression] ICE with type aliases and depedent value
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112633 --- Comment #5 from Hana Dusíková --- Thanks for really quick fix! You are awesome!
[Bug c++/112633] New: ICE in parser GCC 13+ (including 14) around type aliases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112633 Bug ID: 112633 Summary: ICE in parser GCC 13+ (including 14) around type aliases Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Tested on GCC 14.0.0 20231119 (on Compiler-Explorer) and it's giving me ICE, also on all 13.x versions (not 12.x) ```c++ template constexpr bool dependent_true = true; template struct empty_type { }; // something like enable_if template using empty_type_t = typename empty_type::type; struct wrapper { using type = void; }; template using all = wrapper; template using constraints = typename all::type; template >> = nullptr> void calculate() { }; ``` I don't even need to instantiate `calculate` function. It gives me this error: : In substitution of 'template using constraints = typename all::type [with Conditions = {typename empty_type >::type}]': :16:66: required from here 16 | template >> = nullptr> | ^ :14:7: internal compiler error: Segmentation fault 14 | using constraints = typename all::type; | ^~~ 0x26a742e internal_error(char const*, ...) ???:0 0xd276f0 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0xd1b8f3 instantiate_template(tree_node*, tree_node*, int) ???:0 0xd285ea tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0xd35ed6 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int) ???:0 0xd6996f finish_template_type(tree_node*, tree_node*, int) ???:0 0xcf6a49 c_parse_file() ???:0 0xe38e79 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1
[Bug c++/110380] [feature request] "-pg-constexpr=coverage-output" emit coverage metrics for constexpr code evaluated at compile time
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110380 Hana Dusíková changed: What|Removed |Added CC||hanicka at hanicka dot net --- Comment #3 from Hana Dusíková --- This would be really useful for many constexpr only libraries (like CTRE).
[Bug libstdc++/108517] New: std::sort of empty range yield "warning: 'this' pointer is null"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108517 Bug ID: 108517 Summary: std::sort of empty range yield "warning: 'this' pointer is null" Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Bug in GCC 11.1-13 (including trunk) https://compiler-explorer.com/z/EEjeaKfv7 I couldn't minimize it further. Lowering optimization level will make the warning gone.
[Bug c++/102045] New: constructor is not being instantiated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102045 Bug ID: 102045 Summary: constructor is not being instantiated Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- this error is in 11.0+ (including current trunk) and wasn't in gcc-10, the compiler won't emit std::span::span symbol as it should ``` #include struct byte_writer: std::span { using std::span::span; //byte_writer(auto && arg): std::span{arg} { } constexpr void do_something() noexcept { (void)this->empty(); } }; int main() { char array[1]; auto writer = byte_writer{array}; writer.do_something(); } ``` if you explicitly use the constructor (commented out) it will emit the symbol, also the symbol is emitted if `using std::span::span;` is added to the type. https://compiler-explorer.com/z/q8z833eqd
[Bug c++/99637] bit_cast doesn't work with padding bits and it should
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99637 --- Comment #2 from Hana Dusíková --- I know this is not an argument but MSVC accepts this code, meanwhile I'm asking Richard what to do about it.
[Bug c++/99637] New: bit_cast doesn't work with padding bits and it should
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99637 Bug ID: 99637 Summary: bit_cast doesn't work with padding bits and it should Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Standard states in https://eel.is/c++draft/bit.cast#2 "Padding bits of the result are unspecified." Current trunk GCC (11.0.1 20210316) gives error in presence of padding bits: https://compiler-explorer.com/z/MhKMb5 ``` struct my_field { // change size to 64 and it will work unsigned long long a : 63; }; constexpr unsigned long long get_value(const auto & val) noexcept { static_assert(sizeof(val) == sizeof(unsigned long long)); return __builtin_bit_cast(unsigned long long, val); } constexpr auto f = my_field{0}; constexpr auto v = get_value(f); ``` this is the error message GCC gives, but this shouldn't be a hard error ``` :14:29: in 'constexpr' expansion of 'get_value(f)' :10:31: error: '__builtin_bit_cast' accessing uninitialized byte at offset 7 10 | return __builtin_bit_cast(unsigned long long, val); ```
[Bug c++/99013] New: std::source_location::function_name should return same result in constexpr mode and non-constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99013 Bug ID: 99013 Summary: std::source_location::function_name should return same result in constexpr mode and non-constexpr Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Hi found out std::source_location is returning different result in constexpr: ``` #include template constexpr std::string_view get_object_name1() { /*constexpr*/ const char * ptr = std::source_location::current().function_name(); return ptr; } template constexpr std::string_view get_object_name2() { constexpr const char * ptr = std::source_location::current().function_name(); return ptr; } void foo() { } ``` when called `get_object_name1` it returns `constexpr std::string_view get_object_name1() [with auto Object = foo; std::string_view = std::basic_string_view]` but when called `get_object_name2` it returns `constexpr std::string_view get_object_name2()` the difference is the BUG (missing `[with auto Object = foo; std::string_view = std::basic_string_view]`) error with latest trunk on compiler-explorer.com https://compiler-explorer.com/z/4e8Gd1
[Bug c++/98805] exception abort on mac os 11 (big sur)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98805 --- Comment #1 from Hana Dusíková --- I found out that build done on Catalina generates correct binary, which is able to run on Big Sur without any problem.
[Bug c++/98805] New: exception abort on mac os 11 (big sur)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98805 Bug ID: 98805 Summary: exception abort on mac os 11 (big sur) Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Any C++ code I try to compile with GCC 10.2.0 (homebrew package AND build from source) aborts when exception is thrown even when the exception should caught. This minimal example aborts: ``` struct exception { }; int main() { try { throw exception{}; } catch (exception) { } catch (...) { } } ``` (Build with g++ exception.cpp && ./a.out) My GCC build is: ``` Using built-in specs. COLLECT_GCC=/usr/local/gcc-10.2/bin/g++-10.2 COLLECT_LTO_WRAPPER=/usr/local/gcc-10.2/libexec/gcc/x86_64-apple-darwin20.2.0/10.2.0/lto-wrapper Target: x86_64-apple-darwin20.2.0 Configured with: ../gcc-10.2.0/configure --prefix=/usr/local/gcc-10.2 --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk --program-suffix=-10.2 Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (GCC) ``` Backtrace of the binary when crashes is: ``` * frame #0: 0x7fff20347462 libsystem_kernel.dylib`__pthread_kill + 10 frame #1: 0x7fff20375610 libsystem_pthread.dylib`pthread_kill + 263 frame #2: 0x7fff202c8720 libsystem_c.dylib`abort + 120 frame #3: 0x00010048b00a libgcc_s.1.dylib`uw_init_context_1.cold + 5 frame #4: 0x000100488475 libgcc_s.1.dylib`_Unwind_RaiseException(exc=0x000100505760) at unwind.inc:93:3 frame #5: 0x0001001382f7 libstdc++.6.dylib`__cxa_throw + 55 frame #6: 0x00013f13 a.out`main at exception.cpp:5:19 frame #7: 0x7fff20390621 libdyld.dylib`start + 1 ```
[Bug c++/96742] [10/11 Regression] "warning: comparison of unsigned expression in ‘< 0’ is always false" with dependent values
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96742 Hana Dusíková changed: What|Removed |Added CC||hanicka at hanicka dot net --- Comment #7 from Hana Dusíková --- (In reply to Jonathan Wakely from comment #4) > (In reply to William Throwe from comment #2) > > This warns if passed an array of length 0 because the for-loop condition is > > always false. Any change I can make to fix it seems to make the code worse. > > I could replace "i < N" with "i + 1 < N + 1", but that certainly doesn't > > make the code clearer (and in similar cases could lead to weird overflow > > bugs). I can't partially specialize the function, because that's not > > allowed. I could write an implementation struct and specialize that, but > > that seems like massive overkill when the generic function works fine. > > You can use N != 0 && i < N which doesn't have the overflow problem, but I > agree it doesn't make the code clearer, and should not be necessary. This is what I had in CTRE but it's also triggering same warning: https://compiler-explorer.com/z/fjY7sG
[Bug c++/93083] copy deduction rejected when doing CTAD for NTTP
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93083 --- Comment #2 from Hana Dusíková --- Same error is also triggered by template partial specialization: ``` template struct literal { constexpr literal(const char ()[N]) noexcept { } constexpr literal(const literal &) noexcept { } }; template struct field { }; template struct field { }; ```
[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429 Hana Dusíková changed: What|Removed |Added CC||hanicka at hanicka dot net --- Comment #3 from Hana Dusíková --- Hi I run into same issue recently with GCC trunk. EDG, clang, MSVC accept such code.
[Bug c++/88820] [7/8/9 Regression] ICE in in C++2a mode for code which is able to be compiled in C++17 mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88820 --- Comment #9 from Hana Dusíková --- You can have template deduction placeholder there in C++20. https://wg21.link/p0732r2
[Bug c++/88820] ICE in in C++2a mode for code which is able to be compiled in C++17 mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88820 --- Comment #4 from Hana Dusíková --- The ICE will not happen if you comment out line 464 from first example.
[Bug c++/88092] class nontype template deduction failed when providing type to class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092 --- Comment #8 from Hana Dusíková --- Please ignore two last comments, I sent them to wrong bug, it was supposed to be for #88820.
[Bug c++/88820] ICE in in C++2a mode for code which is able to be compiled in C++17 mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88820 --- Comment #2 from Hana Dusíková --- Created attachment 45422 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45422=edit referencing subtype unable to deduce parent type ~/projekty/ice-gcc > g++-HEAD minimal.cpp -std=c++2a -DREFERENCE ~/projekty/ice-gcc > g++-HEAD minimal.cpp -std=c++2a -DAUTO ~/projekty/ice-gcc > g++-HEAD minimal.cpp -std=c++2a -DCNTTP minimal.cpp: In member function 'unsigned int Foo::count()': minimal.cpp:33:19: error: class template argument deduction failed: 33 | return SubType<0>().value(); | ^ minimal.cpp:33:19: error: no matching function for call to 'ArgType(ArgType)' minimal.cpp:8:21: note: candidate: 'template ArgType(const char (&)[N])-> ArgType' 8 | template ArgType(const char (&)[N]) -> ArgType; | ^~~ minimal.cpp:8:21: note: template argument deduction/substitution failed: minimal.cpp:33:19: note: mismatched types 'const char [N]' and 'ArgType' 33 | return SubType<0>().value(); | ^ minimal.cpp:5:12: note: candidate: 'template ArgType(...)-> ArgType' 5 | constexpr ArgType(...) noexcept { } |^~~ minimal.cpp:5:12: note: template argument deduction/substitution failed: minimal.cpp:33:19: note: couldn't deduce template parameter 'N' 33 | return SubType<0>().value(); | ^ minimal.cpp:4:28: note: candidate: 'template ArgType(ArgType)-> ArgType' 4 | template struct ArgType { |^~~ minimal.cpp:4:28: note: template argument deduction/substitution failed: minimal.cpp:33:19: note: mismatched types 'ArgType' and 'ArgType' 33 | return SubType<0>().value(); | ^
[Bug c++/88092] class nontype template deduction failed when providing type to class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092 --- Comment #7 from Hana Dusíková --- If you compile it with: g++-HEAD minimal.cpp -std=c++2a -DREFERENCE => correct g++-HEAD minimal.cpp -std=c++2a -DAUTO => correct g++-HEAD minimal.cpp -std=c++2a -DCNTTP minimal.cpp: In member function 'unsigned int Foo::count()': minimal.cpp:32:19: error: class template argument deduction failed: 32 | return SubType<0>().value(); | ^ minimal.cpp:32:19: error: no matching function for call to 'ArgType(ArgType)' minimal.cpp:11:21: note: candidate: 'template ArgType(const char (&)[N])-> ArgType' 11 | template ArgType(const char (&)[N]) -> ArgType; | ^~~ minimal.cpp:11:21: note: template argument deduction/substitution failed: minimal.cpp:32:19: note: mismatched types 'const char [N]' and 'ArgType' 32 | return SubType<0>().value(); | ^ minimal.cpp:8:12: note: candidate: 'template ArgType(...)-> ArgType' 8 | constexpr ArgType(...) noexcept { } |^~~ minimal.cpp:8:12: note: template argument deduction/substitution failed: minimal.cpp:32:19: note: couldn't deduce template parameter 'N' 32 | return SubType<0>().value(); | ^ minimal.cpp:4:28: note: candidate: 'template ArgType(ArgType)-> ArgType' 4 | template struct ArgType { |^~~ minimal.cpp:4:28: note: template argument deduction/substitution failed: minimal.cpp:32:19: note: mismatched types 'ArgType' and 'ArgType' 32 | return SubType<0>().value(); | ^
[Bug c++/88820] ICE in in C++2a mode for code which is able to be compiled in C++17 mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88820 --- Comment #1 from Hana Dusíková --- I think I found a related problem. It's about deducting argument of a class when instantiating subtype. I created a minimal case. I'm attaching.
[Bug c++/88092] class nontype template deduction failed when providing type to class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092 --- Comment #6 from Hana Dusíková --- Created attachment 45421 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45421=edit argument deduction of parent type
[Bug c++/88820] New: ICE in in C++2a mode for code which is able to be compiled in C++17 mode
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88820 Bug ID: 88820 Summary: ICE in in C++2a mode for code which is able to be compiled in C++17 mode Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Created attachment 45420 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45420=edit one file with all includes included Hi, I found ICE in GCC9-HEAD with CTRE library (I'm author) when I compiled it with C++2a mode. Same code with C++17 mode is compiled correctly, I wasn't able to minimize code which reproduce the error. But I was able to find responsible part of the library and reimplement it differently (problematic part is enabled with -DCTRE_ENABLE_TRAMPOLINING_ON_GCC9) I think that problem is related to class-nontype-template-arguments change in C++2a, check line 314. I'm using GCC9 current head (January 13th 2019). https://gcc.godbolt.org/z/_G0854 (GCC8.2 is compiling correctly the same code.) g++-HEAD test-me.cpp -std=c++17 -DCTRE_ENABLE_TRAMPOLINING_ON_GCC9 -g0 => correct g++-HEAD test-me.cpp -std=c++2a -DCTRE_ENABLE_TRAMPOLINING_ON_GCC9 -g0 => fail : In substitution of 'template template static constexpr auto ctll::parser::trampoline_decide(Subject) [with Subject = ; Grammar = ctll::empty_subject; basic_fixed_string input = ; ActionSelector = ; bool IgnoreUnknownActions = ]': :464:74: required from here :458:68: internal compiler error: tree check: expected tree that contains 'decl minimal' structure, have 'error_mark' in decl_anon_ns_mem_p, at cp/tree.c:3478 458 | template static constexpr auto trampoline_decide(Subject subject = {}) noexcept { | ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 test.me.cpp is attached
[Bug c++/88538] New: parse error with class nontype template parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88538 Bug ID: 88538 Summary: parse error with class nontype template parameter Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Created attachment 45254 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45254=edit parser error on line 12 Compiler should be able to parse attached code in C++2a mode with Class Nontype Template Arguments, instead it's giving me error "parse error in template argument list" Using built-in specs. COLLECT_GCC=g++-HEAD COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/HEAD-0edf78b/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/lto-wrapper Target: x86_64-apple-darwin18.2.0 Configured with: ../configure --build=x86_64-apple-darwin18.2.0 --prefix=/usr/local/Cellar/gcc/HEAD-0edf78b --libdir=/usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran,d --program-suffix=-HEAD --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-system-zlib --with-pkgversion='Homebrew GCC HEAD-0edf78b' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk Thread model: posix gcc version 9.0.0 20181212 (experimental) (Homebrew GCC HEAD-0edf78b) COLLECT_GCC_OPTIONS='-std=c++2a' '-v' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/HEAD-0edf78b/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus -quiet -v -D__DYNAMIC__ gcc9parse-error.cpp -fPIC -quiet -dumpbase gcc9parse-error.cpp -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase gcc9parse-error -std=c++2a -version -o /var/folders/dv/kkg4z5lj0g52m8q8mm0wk6rwgn/T//ccoEsrny.s GNU C++17 (Homebrew GCC HEAD-0edf78b) version 9.0.0 20181212 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181212 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../x86_64-apple-darwin18.2.0/include" ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0 /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/x86_64-apple-darwin18.2.0 /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/backward /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include-fixed /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks End of search list. GNU C++17 (Homebrew GCC HEAD-0edf78b) version 9.0.0 20181212 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181212 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 6936071dc75afe7297cddcec7cf6ee71 gcc9parse-error.cpp: In function 'void f()': gcc9parse-error.cpp:12:5: error: parse error in template argument list 12 | fnc<{10,20}>(); | ^~~~ gcc9parse-error.cpp:12:9: error: expected ';' before '{' token 12 | fnc<{10,20}>(); | ^ | ; gcc9parse-error.cpp:12:5: error: statement cannot resolve address of overloaded function 12 | fnc<{10,20}>(); | ^~~~ gcc9parse-error.cpp:12:16: error: expected primary-expression before '>' token 12 | fnc<{10,20}>(); |^ gcc9parse-error.cpp:12:18: error: expected primary-expression before ')' token 12 | fnc<{10,20}>(); | ^
[Bug c++/88537] New: class nontype template parameter debug mode crash in dwarf2out.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88537 Bug ID: 88537 Summary: class nontype template parameter debug mode crash in dwarf2out.c Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Created attachment 45253 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45253=edit minimal example which will crash with enabled debug symbols I found that gcc is crashing in gcc9crash.cpp:13:1: internal compiler error: in tree_add_const_value_attribute, at dwarf2out.c:20243 when I tried to emit debug symbols in a program with a "class nontype template parameter" Crashing code is attached. You can see it also here: https://gcc.godbolt.org/z/NOkj54 Compilation with: g++-HEAD gcc9crash.cpp -std=c++2a -ggdb -v Using built-in specs. COLLECT_GCC=g++-HEAD COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/HEAD-0edf78b/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/lto-wrapper Target: x86_64-apple-darwin18.2.0 Configured with: ../configure --build=x86_64-apple-darwin18.2.0 --prefix=/usr/local/Cellar/gcc/HEAD-0edf78b --libdir=/usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran,d --program-suffix=-HEAD --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-system-zlib --with-pkgversion='Homebrew GCC HEAD-0edf78b' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk Thread model: posix gcc version 9.0.0 20181212 (experimental) (Homebrew GCC HEAD-0edf78b) COLLECT_GCC_OPTIONS='-std=c++2a' '-ggdb' '-v' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/HEAD-0edf78b/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus -quiet -v -D__DYNAMIC__ gcc9crash.cpp -fPIC -quiet -dumpbase gcc9crash.cpp -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase gcc9crash -ggdb -std=c++2a -version -o /var/folders/dv/kkg4z5lj0g52m8q8mm0wk6rwgn/T//ccQG2L7F.s GNU C++17 (Homebrew GCC HEAD-0edf78b) version 9.0.0 20181212 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181212 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../x86_64-apple-darwin18.2.0/include" ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0 /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/x86_64-apple-darwin18.2.0 /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/backward /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include /usr/local/Cellar/gcc/HEAD-0edf78b/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include-fixed /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks End of search list. GNU C++17 (Homebrew GCC HEAD-0edf78b) version 9.0.0 20181212 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181212 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 6936071dc75afe7297cddcec7cf6ee71 gcc9crash.cpp:13:1: internal compiler error: in tree_add_const_value_attribute, at dwarf2out.c:20243 13 | } | ^ libbacktrace could not find executable to open Please submit a full bug report, with preprocessed source if appropriate.
[Bug c++/88092] class nontype template deduction failed when providing type to class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092 --- Comment #5 from Hana Dusíková --- So minimal example is: template struct S { constexpr S(...) { } }; template S(T) -> S; template struct foo { }; template void fn () { auto t = s; foo f1; foo f2; }
[Bug c++/88092] class nontype template deduction failed when providing type to class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092 --- Comment #4 from Hana Dusíková --- (In reply to Emmanuel Le Trong from comment #3) > I have a problem with this. AFAIK, nowhere in the standard is written that a > class template without argument (i.e. not a type!) can be used as the type > of a non-type template argument. [temp.param] §4 says > > > A non-type template-parameter shall have one of the following (optionally > > cv-qualified) types: > > — a type that is literal, has strong structural equality (10.10.1), has no > > mutable or volatile subobjects, and in which if there is a defaulted member > > operator<=>, then it is declared public, > > — an lvalue reference type, > > — a type that contains a placeholder type (9.1.7.5), or > > — a placeholder for a deduced class type (9.1.7.6). > > So > > template struct A {}; > template struct B {}; > > should not be valid IMO. You are correct, you must have class template argument deduction rule. This should be valid: template struct A { constexpr A(...) {} }; template A(T) -> A; template struct B {};
[Bug c++/88095] New: class nontype template parameter UDL string literals doesn't accepts deduction placeholder
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88095 Bug ID: 88095 Summary: class nontype template parameter UDL string literals doesn't accepts deduction placeholder Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Created attachment 45035 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45035=edit small example I tried CNTTP support for string literals, and gives me error: error: literal operator template 'constexpr bool operator""_test()' has invalid parameter list; Expected non-type template parameter packor single non-type parameter of class type It should (by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0732r2.pdf) accept deduction placeholder: template constexpr bool operator"" _test() { return true; } (whole example in attachment) GCC 9.0 head (20f6624) - g++-HEAD -v -save-temps -std=c++2a cnttp3.cpp Using built-in specs. COLLECT_GCC=g++-HEAD COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/lto-wrapper Target: x86_64-apple-darwin18.2.0 Configured with: ../configure --build=x86_64-apple-darwin18.2.0 --prefix=/usr/local/Cellar/gcc/HEAD-20f6624 --libdir=/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-HEAD --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-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC HEAD-20f6624' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-nls --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk Thread model: posix gcc version 9.0.0 20181118 (experimental) (Homebrew GCC HEAD-20f6624) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++2a' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus -E -quiet -v -D__DYNAMIC__ cnttp3.cpp -fPIC -mmacosx-version-min=10.14.0 -mtune=core2 -std=c++2a -fpch-preprocess -o cnttp3.ii ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../x86_64-apple-darwin18.2.0/include" ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0 /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/x86_64-apple-darwin18.2.0 /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/backward /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include-fixed /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++2a' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus -fpreprocessed cnttp3.ii -fPIC -quiet -dumpbase cnttp3.cpp -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase cnttp3 -std=c++2a -version -o cnttp3.s GNU C++17 (Homebrew GCC HEAD-20f6624) version 9.0.0 20181118 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181118 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++17 (Homebrew GCC HEAD-20f6624) version 9.0.0 20181118 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181118 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: ac5ba3fc9d630765279df693b1849957 cnttp3.cpp:12:1: error: literal operator template 'constexpr bool operator""_test()' has invalid parameter list; Expected non-type template parameter packor single non-type parameter of class type 12 | } | ^
[Bug c++/88092] New: class nontype template deduction failed when providing type to class
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092 Bug ID: 88092 Summary: class nontype template deduction failed when providing type to class Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hanicka at hanicka dot net Target Milestone: --- Created attachment 45034 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45034=edit minimal example (workaround is also part of the code) I found that a type deduction placeholder in class nontype template parameter is not resolved properly if given as template argument to a class. GCC 9 HEAD (commit: 20f6624). Example attached with marked problem. Also found workaround using function template with a class nontype template parameter. Using built-in specs. COLLECT_GCC=g++-HEAD COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/lto-wrapper Target: x86_64-apple-darwin18.2.0 Configured with: ../configure --build=x86_64-apple-darwin18.2.0 --prefix=/usr/local/Cellar/gcc/HEAD-20f6624 --libdir=/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-HEAD --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-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC HEAD-20f6624' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-nls --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk Thread model: posix gcc version 9.0.0 20181118 (experimental) (Homebrew GCC HEAD-20f6624) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++2a' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus -E -quiet -v -D__DYNAMIC__ cnttp2.cpp -fPIC -mmacosx-version-min=10.14.0 -mtune=core2 -std=c++2a -fpch-preprocess -o cnttp2.ii ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../x86_64-apple-darwin18.2.0/include" ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0 /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/x86_64-apple-darwin18.2.0 /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/backward /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include /usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include-fixed /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++2a' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus -fpreprocessed cnttp2.ii -fPIC -quiet -dumpbase cnttp2.cpp -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase cnttp2 -std=c++2a -version -o cnttp2.s GNU C++17 (Homebrew GCC HEAD-20f6624) version 9.0.0 20181118 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181118 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++17 (Homebrew GCC HEAD-20f6624) version 9.0.0 20181118 (experimental) (x86_64-apple-darwin18.2.0) compiled by GNU C version 9.0.0 20181118 (experimental), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: ac5ba3fc9d630765279df693b1849957 cnttp2.cpp: In function 'constexpr void test()': cnttp2.cpp:20:19: error: class template argument deduction failed: 20 | using t3 = foo; // <- this fails | ^ cnttp2.cpp:20:19: error: no matching function for call to 'fixed_string(fixed_string)' cnttp2.cpp:7:42: note: candidate: 'template fixed_string(const CharT (&)[N])-> fixed_string' 7