This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12359] New: template specialization broken when typeof(var) used with template class
- From: "mbartosik at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Sep 2003 01:42:14 -0000
- Subject: [Bug c++/12359] New: template specialization broken when typeof(var) used with template class
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12359
Summary: template specialization broken when typeof(var) used
with template class
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mbartosik at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
#include <iostream>
// Bug in GCC 3.3.1 (tested with MinGW)
// also in GCC 3.2.3 (tested with MinGW)
// template specialization lookup is broken when typeof(var) is
// provided as a template argument within a template class.
template <typename T> struct trait { typedef void return_t; };
template <> struct trait<int> { typedef char return_t; };
template <> struct trait<long> { typedef float return_t; };
int my_int;
template <typename T> struct working
{
inline typename ::trait<typeof(int)>::return_t foo()
{
return 'a';
}
};
struct working_also
{
inline ::trait<typeof(my_int)>::return_t foo()
{
return 'b';
}
};
template <typename T> struct broken
{
inline typename ::trait<typeof(my_int)>::return_t foo() // yields wrong
specialization of ::trait<int>
{
typeof(my_int) val = 3;
return 'c';
}
};
int main()
{
working<int> a;
working_also b;
broken<int> c;
// Should output abc, but c.foo() incorrectly returns void
std::cout << a.foo() << b.foo() << c.foo();
return 0;
}