c++/3767: c++ ice-on-illegal code
mayer@tux.org
mayer@tux.org
Sun Jul 22 21:56:00 GMT 2001
>Number: 3767
>Category: c++
>Synopsis: c++ ice-on-illegal code
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: unassigned
>State: open
>Class: ice-on-illegal-code
>Submitter-Id: net
>Arrival-Date: Sun Jul 22 21:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Uwe F. Mayer
>Release: 3.0
>Organization:
tux.org
>Environment:
System: Linux tosca 2.2.18 #2 Thu Mar 8 13:48:25 PST 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0/configure --disable-nls --prefix=/usr/local/gcc-3.0
>Description:
I used a declaration "T::Y *z;" for a template parameter T and a subclass Y
of the instantiated class T. The compiler decided that this is multiplication,
and gave me an internal compiler error. I am not sure whether the code I wrote
is actually legal. Here is the output of the compilation attempt:
g++ -Wall typename.cc
typename.cc: In member function `void X<T>::foo() [with T = Z]':
typename.cc:28: instantiated from here
typename.cc:8: Internal compiler error in c_expand_expr, at c-common.c:4116
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
>How-To-Repeat:
Compile the program typename.cc:
#include <iostream>
using namespace std;
template<class T>
class X {
public:
void foo(){
T::Y *z; // situation interpreted by g++ as
// multiplication, not definition
//typename T::Y * z; // definition forced, compiles OK
}
int z;
};
class Z {
public:
class Y {
public:
int i;
friend int operator*(Z::Y y, int j);
};
};
int operator*(Z::Y y, int j) {return(y.i*j);}
int main() {
X<Z> x;
x.foo();
}
>Fix:
Remove the ambiguity with "typename".
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list