https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85262
Bug ID: 85262 Summary: [6/7/8 Regression] Trouble with constructor and -fpermissive Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: ice-on-valid-code, rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: reichelt at gcc dot gnu.org Target Milestone: --- The following valid code snippet (compiled with "-fpermissive") triggers an ICE on trunk: ================================ struct A {}; template<int> struct B : A { B() { A::A(A()); } }; B<0> b; ================================ bug.cc: In constructor 'B<<anonymous> >::B()': bug.cc:7:13: warning: cannot call constructor 'A::A' directly [-fpermissive] A::A(A()); ^ bug.cc:7:13: note: for a function-style cast, remove the redundant '::A' bug.cc: In instantiation of 'B<<anonymous> >::B() [with int <anonymous> = 0]': bug.cc:11:6: required from here bug.cc:7:10: internal compiler error: in tsubst_copy, at cp/pt.c:15625 A::A(A()); ^~~ 0x63a8eb tsubst_copy ../../gcc/gcc/cp/pt.c:15625 0x96682b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:18658 0x967f8c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:18295 0x965a11 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:17543 0x971627 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:17099 0x97092e tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:16300 0x96e71f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:16583 0x97005c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:16286 0x96e71f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:16583 0x96d8b8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:16271 0x96d8b8 instantiate_decl(tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:23682 0x99476b instantiate_pending_templates(int) ../../gcc/gcc/cp/pt.c:23798 0x8b8e3b c_parse_final_cleanups() ../../gcc/gcc/cp/decl2.c:4725 Please submit a full bug report, [etc.] In GCC 6 and GCC 7 the code is wrongly rejected (when parsing the template, the call to A::A is accepted with "-fpermissive", but at instantiation time it is rejected) while a version without template compiles: bug.cc: In constructor 'B<<anonymous> >::B()': bu5.cc:7:13: warning: cannot call constructor 'A::A' directly [-fpermissive] A::A(A()); ^ bug.cc:7:13: note: for a function-style cast, remove the redundant '::A' bug.cc: In instantiation of 'B<<anonymous> >::B() [with int <anonymous> = 0]': bug.cc:11:6: required from here bug.cc:7:9: error: cannot call constructor 'A::A' directly A::A(A()); ~~~~^~~~~