c++/10468: const typeof(x) is non-const, but only in templates
bangerth@dealii.org
bangerth@dealii.org
Wed Apr 30 16:47:00 GMT 2003
Old Synopsis: Type interpreted as int& instead of const int&
New Synopsis: const typeof(x) is non-const, but only in templates
State-Changed-From-To: feedback->analyzed
State-Changed-By: bangerth
State-Changed-When: Wed Apr 30 14:52:04 2003
State-Changed-Why:
I'm sorry, I just misread the original example and missed
the const keyword. Indeed, I agree. The problem is best
exemplified with this snippet:
--------------------------------
template <class T>
void test1() {
int x = 0;
const typeof(x) & t1 = x+0;
}
void test2() {
int x = 0;
const typeof(x) & t1 = x+0;
}
int main() {
test1<int>();
test2 ();
}
-------------------------
While test2 compiles just fine, test1 doesn't, although
it's all the same except for the fact that it is a
template. Here's the message with present 3.4:
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/bin/c++ -c x.cc
x.cc: In function `void test1() [with T = int]':
x.cc:13: instantiated from here
x.cc:4: error: could not convert `x' to `int&'
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10468
More information about the Gcc-bugs
mailing list