[Bug c++/11077] New: enumerator value in template not assignable from bool
numerical.simulation@web.de
gcc-bugzilla@gcc.gnu.org
Tue Jun 3 10:23:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11077
Summary: enumerator value in template not assignable from bool
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: blocker
Priority: P2
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: numerical.simulation@web.de
CC: gcc-bugs@gcc.gnu.org,numerical.simulation@web.de
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
The following code does not compile with gcc, though it is valid C++ (IMHO)
#include <iostream>
template<class T>
class has_member_disambiguation // Thanks to Paul Mensonides
{
protected:
template<class U> static char check(typename U::Disambiguation*);
template<class U> static char (& check(...))[2];
public:
enum { value = (sizeof(check<T>(0)) == 1) };
};
struct A
{
typedef double Disambiguation;
};
struct B {};
int main()
{
std::cerr << has_member_disambiguation<A>::value << std::endl;
std::cerr << has_member_disambiguation<B>::value << std::endl;
}
g++ ~/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C: In instantiation of
`has_member_disambiguation<A>':
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:24: instantiated from
here
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:11: error: invalid use of
undefined type `class has_member_disambiguation<A>'
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:5: error: declaration of `
class has_member_disambiguation<A>'
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:11: error: enumerator
value for `value' not integer constant
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C: In instantiation of
`has_member_disambiguation<B>':
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:25: instantiated from
here
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:11: error: invalid use of
undefined type `class has_member_disambiguation<B>'
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:5: error: declaration of `
class has_member_disambiguation<B>'
/home/markus/hp-home/C++/EXPERIMENTAL/GCC-3.4-Bugs.C:11: error: enumerator
value for `value' not integer constant
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the Gcc-bugs
mailing list