This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/10468: const typeof(x) is non-const, but only in templates
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, mgoodman at csua dot berkeley dot edu, nobody at gcc dot gnu dot org
- Date: 30 Apr 2003 14:52:04 -0000
- Subject: Re: c++/10468: const typeof(x) is non-const, but only in templates
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, mgoodman at csua dot berkeley dot edu, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
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