c++/8572: ICE with external definition of conversion operator to internal class within template class

llib@computer.org llib@computer.org
Wed Nov 13 21:26:00 GMT 2002


>Number:         8572
>Category:       c++
>Synopsis:       ICE with external definition of conversion operator to internal class within template class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 13 21:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Bill Clarke
>Release:        3.3 20021110 (experimental)
>Organization:
>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++
>Description:
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.

>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.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list