https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79091
Bug ID: 79091 Summary: [7 regression] ICE in write_unnamed_type Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: s...@li-snyder.org Target Milestone: --- hi - gcc version 7.0.0 20170111 gives an ICE for this example (tested on x86_64-pc-linux-gnu): ================================================================ enum { ColMajor = 0 }; template<int Rows, int Options = (Rows==1) ? 1 : ColMajor > class Matrix {}; class RotationBase { public: Matrix<3> toRotationMatrix() const; }; template<int Dim> Matrix<Dim> toRotationMatrix(const RotationBase& r) { return r.toRotationMatrix(); } class Transform { public: Transform(const RotationBase& r) { toRotationMatrix<3>(r); } }; void localStripPos() { RotationBase t2; Transform transfPtr_internalgeo(t2); } ================================================================ $ cc1plus -v x.cc Matrix<Dim> toRotationMatrix(const RotationBase&) Transform::Transform(const RotationBase&) Matrix<3> Transform::Transform(const RotationBase&) Transform::Transform(const RotationBase&) void localStripPos() Matrix<Dim> toRotationMatrix(const RotationBase&) [with int Dim = 3] Analyzing compilation unit x.cc: In instantiation of ‘Matrix<Dim> toRotationMatrix(const RotationBase&) [with int Dim = 3]’: x.cc:17:13: internal compiler error: in write_unnamed_type_name, at cp/mangle.c:1623 Matrix<Dim> toRotationMatrix(const RotationBase& r) ^~~~~~~~~~~~~~~~ 0xa4755c write_unnamed_type_name /home/sss/gcc/gcc/gcc/cp/mangle.c:1623 0xa4642a write_unqualified_name /home/sss/gcc/gcc/gcc/cp/mangle.c:1382 0xa43af6 write_unscoped_name /home/sss/gcc/gcc/gcc/cp/mangle.c:1007 0xa43857 write_name /home/sss/gcc/gcc/gcc/cp/mangle.c:939 0xa4dd94 write_class_enum_type /home/sss/gcc/gcc/gcc/cp/mangle.c:2769 0xa4a825 write_type /home/sss/gcc/gcc/gcc/cp/mangle.c:2187 0xa51b76 write_template_arg_literal /home/sss/gcc/gcc/gcc/cp/mangle.c:3341 0xa4e4d6 write_expression /home/sss/gcc/gcc/gcc/cp/mangle.c:2883 0xa51ac4 write_expression /home/sss/gcc/gcc/gcc/cp/mangle.c:3324 0xa529ae write_template_arg /home/sss/gcc/gcc/gcc/cp/mangle.c:3485 0xa4df09 write_template_args /home/sss/gcc/gcc/gcc/cp/mangle.c:2798 0xa43846 write_name /home/sss/gcc/gcc/gcc/cp/mangle.c:935 0xa4dd94 write_class_enum_type /home/sss/gcc/gcc/gcc/cp/mangle.c:2769 0xa4a825 write_type /home/sss/gcc/gcc/gcc/cp/mangle.c:2187 0xa4da08 write_bare_function_type /home/sss/gcc/gcc/gcc/cp/mangle.c:2692 0xa431a5 write_encoding /home/sss/gcc/gcc/gcc/cp/mangle.c:848 0xa42b96 write_mangled_name /home/sss/gcc/gcc/gcc/cp/mangle.c:788 0xa539a1 mangle_decl_string /home/sss/gcc/gcc/gcc/cp/mangle.c:3743 0xa539e7 get_mangled_id /home/sss/gcc/gcc/gcc/cp/mangle.c:3765 0xa53eab mangle_decl(tree_node*) /home/sss/gcc/gcc/gcc/cp/mangle.c:3835 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. The assertion that trips is in mangle.c:write_unnamed_type_name, here: write_unnamed_type_name (const tree type) { int discriminator; MANGLE_TRACE_TREE ("unnamed-type-name", type); if (TYPE_FUNCTION_SCOPE_P (type)) discriminator = local_class_index (type); else if (TYPE_CLASS_SCOPE_P (type)) discriminator = nested_anon_class_index (type); else { gcc_assert (no_linkage_check (type, /*relaxed_p=*/true)); /* Just use the old mangling at namespace scope. */ write_source_name (TYPE_IDENTIFIER (type)); return; } where TYPE is <enumeral_type 0x7ffff0033d20 ._0 type <integer_type 0x7ffff0033dc8 unsigned int public unsigned SI size <integer_cst 0x7fffefee9108 constant 32> unit size <integer_cst 0x7fffefee9120 constant 4> align 32 symtab 0 alias set -1 canonical type 0x7ffff0033dc8 precision 1 min <integer_cst 0x7ffff0045be8 0> max <integer_cst 0x7ffff0045c00 1>> unsigned type_6 SI size <integer_cst 0x7fffefee9108 32> unit size <integer_cst 0x7fffefee9120 4> align 32 symtab 0 alias set -1 canonical type 0x7ffff0033d20 precision 32 min <integer_cst 0x7fffefee9138 0> max <integer_cst 0x7fffefee90f0 4294967295> values <tree_list 0x7ffff002ded8 purpose <identifier_node 0x7ffff0048bb0 ColMajor bindings <0x7ffff002deb0> local bindings <(nil)>> value <const_decl 0x7fffefee4150 ColMajor type <enumeral_type 0x7ffff0033d20 ._0> readonly constant used VOID file x.cc line 2 col 3 align 1 context <enumeral_type 0x7ffff0033d20 ._0> initial <integer_cst 0x7ffff0045c18 0> chain <type_decl 0x7ffff0035e40 ._0>>> context <translation_unit_decl 0x7fffefed5168 D.1> chain <type_decl 0x7ffff0035e40 ._0>>