This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1514: template operator<< call within constructor



>Number:         1514
>Category:       c++
>Synopsis:       template operator<< call within constructor
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 27 02:36:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Neil Pearce
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
gilbert% uname -a
SunOS gilbert 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-5_10
gilbert% g++ -v 
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)

NOTE: This g++ was a binary release obtained from the
SunFreeWare.com site
>Description:
The following c++ source code generates an internal
compiler error.

class Foo {
public:
  Foo() {
    *this << "foo";
  }

  template<class T>
  Foo& operator<<(const T& t) {
    return *this;
  }
};

int main() {
  Foo foo;
}


gilbert% g++ -v -save-temps x.cc
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) x.cc x.ii
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/../../../../include/g++-3
 /usr/local/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/../../../../sparc-sun-solaris2.7/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cc1plus x.ii -quiet -dumpbase x.cc -version -o x.s
GNU C++ version 2.95.2 19991024 (release) (sparc-sun-solaris2.7) compiled by GNU C version 2.95.2 19991024 (release).
x.cc: In method `class Foo & Foo::operator <<<char[4]>(const char (&)[4])':
x.cc:4:   instantiated from here
x.cc:8: Internal compiler error.
x.cc:8: Please submit a full bug report.
x.cc:8: See <URL:http://www.gnu.org/software/gcc/faq.html#bugreport> for instructions.


gilbert% cat x.ii
# 1 "x.cc"
class Foo {
public:
  Foo() {
    *this << "foo";
  }

  template<class T>
  Foo& operator<<(const T& t) {
    return *this;
  }
};

int main() {
  Foo foo;
}
>How-To-Repeat:
Attempting to compile the source code with
  g++ x.cc

Results in Internal compiler error, as detailed above.

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]