public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11077] New: enumerator value in template not assignable from bool
@ 2003-06-03 10:23 numerical.simulation@web.de
  2003-06-03 12:36 ` [Bug c++/11077] " pinskia@physics.uc.edu
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: numerical.simulation@web.de @ 2003-06-03 10:23 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-06-03 17:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-03 10:23 [Bug c++/11077] New: enumerator value in template not assignable from bool numerical.simulation@web.de
2003-06-03 12:36 ` [Bug c++/11077] " pinskia@physics.uc.edu
2003-06-03 12:42 ` reichelt@gcc.gnu.org
2003-06-03 13:14 ` numerical.simulation@web.de
2003-06-03 13:23 ` pinskia@physics.uc.edu
2003-06-03 17:13 ` giovannibajo@libero.it

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).