The following code contains a test template is_class which tries to determine, if the given argument is a class. Unlike other implementations it should not return true if the argument is a union. I have used the 'substitution failure is not an error' principle but g++ V3.3.5 (Debian 1:3.3.5-12) (i486-linux) fails with an error though it has a default function available. Since I do not have the standard I can't declare this a bug. ---- bug.c cusing namespace std; #include <iostream> template<typename _T> struct is_class { typedef char no; struct yes { char c[2]; }; template<typename _U> struct c: _U { c(int); }; template<typename _U> static no test (...); template<typename _U> static yes test(c<_U>); static const bool v = (sizeof (test<_T>(0))==sizeof(yes)); }; union u { int i; double f; }; struct c {}; int main (void) { cout << "union:" << is_class<u>::v << endl; cout << "class:" << is_class<c>::v << endl; cout << "int:" << is_class<int>::v << endl; return 0; };
-- Summary: Possible bug Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sven at clio dot in-berlin dot de CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i486-linux GCC host triplet: i486-linux GCC target triplet: i486-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21510