public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/113620] New: Specialized Template @ 2024-01-26 15:10 hans.buchmann.wantuch at gmail dot com 2024-01-26 15:37 ` [Bug c++/113620] " xry111 at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: hans.buchmann.wantuch at gmail dot com @ 2024-01-26 15:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113620 Bug ID: 113620 Summary: Specialized Template Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hans.buchmann.wantuch at gmail dot com Target Milestone: --- Created attachment 57225 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57225&action=edit Bug report generated with: -freport-bug Compiling the code bug-1.cc ------8<------8<------8<------8<------ class CRC { public: template<typename T> struct Def { using TYP=T; static const TYP INIT=0; }; enum Method {MSB_FIRST,LSB_FIRST}; template<Method M,typename DEF> class BIT{}; template<typename DEF> struct BIT<MSB_FIRST,DEF> { DEF::TYP r=DEF::INIT; }; }; int main(int argc,char** args) { CRC::BIT<CRC::MSB_FIRST,CRC::Def<unsigned short>> crc; return 0; } ------8<------8<------8<------8<------ compiling with: g++ -freport-bug -std=c++2a -c -o bug-1.o bug-1.cc results in the following output: see attached bug-report.txt Sincerely Hans Buchmann ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113620] Specialized Template 2024-01-26 15:10 [Bug c++/113620] New: Specialized Template hans.buchmann.wantuch at gmail dot com @ 2024-01-26 15:37 ` xry111 at gcc dot gnu.org 2024-01-26 16:58 ` [Bug c++/113620] ICE with missing "typename" and -std=c++20 pinskia at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: xry111 at gcc dot gnu.org @ 2024-01-26 15:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113620 Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org Status|UNCONFIRMED |NEW Keywords| |ice-on-invalid-code Ever confirmed|0 |1 Last reconfirmed| |2024-01-26 --- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- Confirmed. t1.c:19:21: internal compiler error: tree check: accessed elt 2 of 'tree_vec' with 1 elts in tsubst, at cp/pt.cc:16216 19 | DEF::TYP r=DEF::INIT; | ^~~~ 0x910d44 tree_vec_elt_check_failed(int, int, char const*, int, char const*) ../../gcc/gcc/tree.cc:9153 0x7a8e83 tree_vec_elt_check(tree_node*, int, char const*, int, char const*) ../../gcc/gcc/tree.h:3865 0x7a8e83 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.cc:16216 0xc3ada0 tsubst_scope ../../gcc/gcc/cp/pt.cc:16857 0xc3ada0 tsubst_qualified_id ../../gcc/gcc/cp/pt.cc:17133 0xc153cd tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.cc:20199 0xb03627 maybe_instantiate_nsdmi_init(tree_node*, int) ../../gcc/gcc/cp/init.cc:624 0xb03b0a maybe_instantiate_nsdmi_init(tree_node*, int) ../../gcc/gcc/cp/init.cc:679 0xb03b0a get_nsdmi(tree_node*, bool, int) ../../gcc/gcc/cp/init.cc:656 0xb34ed1 walk_field_subobs ../../gcc/gcc/cp/method.cc:2466 0xb35576 walk_field_subobs ../../gcc/gcc/cp/method.cc:2390 0xb35576 synthesized_method_walk ../../gcc/gcc/cp/method.cc:2835 0xb35eed get_defaulted_eh_spec(tree_node*, int) ../../gcc/gcc/cp/method.cc:2877 0xc1a078 maybe_instantiate_noexcept(tree_node*, int) ../../gcc/gcc/cp/pt.cc:26655 0xc19ee6 maybe_instantiate_noexcept(tree_node*, int) ../../gcc/gcc/cp/pt.cc:26645 0xae729a mark_used(tree_node*, int) ../../gcc/gcc/cp/decl2.cc:5811 0xa1af3e build_over_call ../../gcc/gcc/cp/call.cc:10524 0xa183bf build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) ../../gcc/gcc/cp/call.cc:11796 0xa1962a build_special_member_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, int) ../../gcc/gcc/cp/call.cc:11281 0xb07819 expand_default_init ../../gcc/gcc/cp/init.cc:2202 With -std=c++17 it's fine: t1.c:19:5: error: need 'typename' before 'DEF::TYP' because 'DEF' is a dependent scope 19 | DEF::TYP r=DEF::INIT; | ^~~ | typename ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113620] ICE with missing "typename" and -std=c++20 2024-01-26 15:10 [Bug c++/113620] New: Specialized Template hans.buchmann.wantuch at gmail dot com 2024-01-26 15:37 ` [Bug c++/113620] " xry111 at gcc dot gnu.org @ 2024-01-26 16:58 ` pinskia at gcc dot gnu.org 2024-01-26 16:59 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-01-26 16:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113620 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-invalid-code |ice-on-valid-code Known to fail| |5.1.0 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Xi Ruoyao from comment #1) > With -std=c++17 it's fine: > > t1.c:19:5: error: need 'typename' before 'DEF::TYP' because 'DEF' is a > dependent scope > 19 | DEF::TYP r=DEF::INIT; > | ^~~ > | typename Note once you add the typename (which is optional in C++20 by the way), the ICE is back in C++11 mode even. This has been ICEing from at least GCC 5.1.0. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113620] ICE with missing "typename" and -std=c++20 2024-01-26 15:10 [Bug c++/113620] New: Specialized Template hans.buchmann.wantuch at gmail dot com 2024-01-26 15:37 ` [Bug c++/113620] " xry111 at gcc dot gnu.org 2024-01-26 16:58 ` [Bug c++/113620] ICE with missing "typename" and -std=c++20 pinskia at gcc dot gnu.org @ 2024-01-26 16:59 ` pinskia at gcc dot gnu.org 2024-01-26 17:11 ` [Bug c++/113620] ICE with inner class template speciailization and depdent NSDMI pinskia at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-01-26 16:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113620 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |4.9.0 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- In GCC 4.8.5, it was rejected (incorrectly): ``` <source>:19:25: error: 'DEF' has not been declared typename DEF::TYP r=DEF::INIT; ^ ``` ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113620] ICE with inner class template speciailization and depdent NSDMI 2024-01-26 15:10 [Bug c++/113620] New: Specialized Template hans.buchmann.wantuch at gmail dot com ` (2 preceding siblings ...) 2024-01-26 16:59 ` pinskia at gcc dot gnu.org @ 2024-01-26 17:11 ` pinskia at gcc dot gnu.org 2024-01-26 18:04 ` ppalka at gcc dot gnu.org 2024-01-26 18:39 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-01-26 17:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113620 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 57229 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57229&action=edit Reduced testcase I reduced the testcase slightly to show it is NSDMI related dealing with a dependent value only with the specialization. Note a workaround is to add a constructor which does the initialization instead of using NSDMI. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113620] ICE with inner class template speciailization and depdent NSDMI 2024-01-26 15:10 [Bug c++/113620] New: Specialized Template hans.buchmann.wantuch at gmail dot com ` (3 preceding siblings ...) 2024-01-26 17:11 ` [Bug c++/113620] ICE with inner class template speciailization and depdent NSDMI pinskia at gcc dot gnu.org @ 2024-01-26 18:04 ` ppalka at gcc dot gnu.org 2024-01-26 18:39 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: ppalka at gcc dot gnu.org @ 2024-01-26 18:04 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113620 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> --- Seems to be a name lookup issue ultimately: struct A { template<class T, class U> struct B; template<class V> struct B<int, V> { int x = V::value; // error: 'V' has not been declared int y = T::value; // no error! int z = U::value; // no error! }; }; ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113620] ICE with inner class template speciailization and depdent NSDMI 2024-01-26 15:10 [Bug c++/113620] New: Specialized Template hans.buchmann.wantuch at gmail dot com ` (4 preceding siblings ...) 2024-01-26 18:04 ` ppalka at gcc dot gnu.org @ 2024-01-26 18:39 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-01-26 18:39 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113620 --- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Patrick Palka from comment #5) > Seems to be a name lookup issue ultimately: > > struct A { > template<class T, class U> > struct B; > > template<class V> > struct B<int, V> { > int x = V::value; // error: 'V' has not been declared > int y = T::value; // no error! > int z = U::value; // no error! > }; > }; That would make sense on why it was rejected before GCC 4.9 even. Now I wonder if this is related to the diagnostic issue mentioned in https://gcc.gnu.org/pipermail/gcc-patches/2024-January/643811.html even. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-01-26 18:39 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-01-26 15:10 [Bug c++/113620] New: Specialized Template hans.buchmann.wantuch at gmail dot com 2024-01-26 15:37 ` [Bug c++/113620] " xry111 at gcc dot gnu.org 2024-01-26 16:58 ` [Bug c++/113620] ICE with missing "typename" and -std=c++20 pinskia at gcc dot gnu.org 2024-01-26 16:59 ` pinskia at gcc dot gnu.org 2024-01-26 17:11 ` [Bug c++/113620] ICE with inner class template speciailization and depdent NSDMI pinskia at gcc dot gnu.org 2024-01-26 18:04 ` ppalka at gcc dot gnu.org 2024-01-26 18:39 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).