$ cat >test.cxx
#include <iostream>
using std::cerr;
using std::endl;
template <typename X>
struct test
{
static int const r = 0;
};
template <typename X>
struct test<X&>
{
static int const r = 1;
};
template <typename X>
struct test<X*>
{
static int const r = 2;
};
int
main ()
{
int i;
int& ri = i;
int* pi = &i;
cerr << test<typeof (i)>::r << endl;
cerr << test<typeof (ri)>::r << endl;
cerr << test<typeof (pi)>::r << endl;
cerr << test<typeof (int)>::r << endl;
cerr << test<typeof (int&)>::r << endl;
cerr << test<typeof (int*)>::r << endl;
}
$ g++-4.0 --version
g++-4.0 (GCC) 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)
$ g++-4.0 test.cxx
$ ./a.out
0
0
2
0
1
2
--
Summary: typeof strips cv-qualification
Product: gcc
Version: 4.0.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: boris at kolpackov dot net
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25555