internal compiler error with legal code (see How-To-Repeat) results in internal compiler error: templ-bug.cc:18: internal compiler error: in mangle_conv_op_name_for_type, at cp/mangle.c:2612 The problem occurs with a template class X<T>, that has a conversion operator to a pointer to an internal class X<T>::Y, where the conversion operator is defined external to the class. The problem does not occur with Z, since it is defined within the template definition. Release: 3.3 20021110 (experimental) Environment: System: SunOS alto 5.9 Generic sun4u sparc SUNW,Sun-Blade-1000 Architecture: sun4 host: sparc-sun-solaris2.9 build: sparc-sun-solaris2.9 target: sparc-sun-solaris2.9 configured with: ../gcc/configure --enable-languages=c,c++ How-To-Repeat: compile this code: // templ-bug.cc template <typename T> struct X { struct Y { Y() { } }; operator Y* () const; struct Z { Z() { } }; operator Z* () const { return 0; } }; // implementation: template <typename T> X<T>::operator typename X<T>::Y*() const { // this is line 18 return 0; } // eof ? ~/incoming/gcc-mainline-cvs/install/bin/g++ -c templ-bug.cc templ-bug.cc:18: internal compiler error: in mangle_conv_op_name_for_type, at cp/mangle.c:2612 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. ?
Fix: workaround: define the conversion operator within the class.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. It works with 3.2.1pre and 2.95, so is a recent regression. Also fails on Linux, so is not target specific. On my list of "templates & conversion operators", I also have PRs 383 and 8578.
From: Janis Johnson <janis187@us.ibm.com> To: llib@computer.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c++/8572: [3.3 regression] ICE with external definition of conversion operator to internal class within template class Date: Wed, 11 Dec 2002 16:50:34 -0800 The regression reported in PR c++/8572 showed up starting with this patch, which might merely uncover an existing problem: 2002-03-20 Nathan Sidwell <nathan@codesourcery.com> PR c++/4361 * mangle.c (struct globals) Add internal_mangling_p member. (write_template_param): Do internal mangling, if needed. (mangle_conv_op_name_for_type): Request internal mangling. Here's a small test case that causes the ICE, which occurs in the mainline but not in the 3.2 branch: --------------- template <typename T> struct A { struct B { B() {} }; operator B* () const; }; template <typename T> A<T>::operator typename A<T>::B*() const { return 0; } --------------- Compiler output from the mainline with this test: 8572.C:7: internal compiler error: in mangle_conv_op_name_for_type, at cp/mangle.c:2612 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8572
*** This bug has been marked as a duplicate of 8702 ***
From: nathan@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/8572 Date: 22 Dec 2002 21:32:28 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2002-12-22 13:32:28 Modified files: gcc/cp : ChangeLog cp-tree.h decl2.c parse.y gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: conv_op1.C Log message: cp: PR c++/8572 * cp-tree.h (grokoptypename): Add SCOPE parameter. * decl2.c (grokoptypename): Add SCOPE parameter. tsubst the type if in a template scope. * parse.y (unoperator): Return the scope. (operator_name): Adjust grokoptypename call. testsuite: * g++.dg/parse/conv_op1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3087&r2=1.3088 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.780&r2=1.781 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.577&r2=1.578 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parse.y.diff?cvsroot=gcc&r1=1.286&r2=1.287 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2272&r2=1.2273 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/conv_op1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
State-Changed-From-To: analyzed->closed State-Changed-Why: 2002-12-22 Nathan Sidwell <nathan@codesourcery.com> PR c++/8572 * cp-tree.h (grokoptypename): Add SCOPE parameter. * decl2.c (grokoptypename): Add SCOPE parameter. tsubst the type if in a template scope. * parse.y (unoperator): Return the scope. (operator_name): Adjust grokoptypename call.
From: nathan@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/8572 Date: 23 Dec 2002 13:45:39 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: nathan@gcc.gnu.org 2002-12-23 05:45:39 Modified files: gcc/cp : ChangeLog parse.y cp-tree.h decl2.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: conv_op1.C Log message: cp: PR c++/8572 * cp-tree.h (grokoptypename): Add SCOPE parameter. * decl2.c (grokoptypename): Add SCOPE parameter. tsubst the type if in a template scope. * parse.y (unoperator): Return the scope. (operator_name): Adjust grokoptypename call. testsuite: * g++.dg/parse/conv_op1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.6&r2=1.3076.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parse.y.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.284.2.1&r2=1.284.2.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.776.2.1&r2=1.776.2.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.575.2.1&r2=1.575.2.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.5&r2=1.2261.2.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/conv_op1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1