[Bug c++/53788] C++11 decltype sfinae static member function check (4.7.1)

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 28 10:36:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53788

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-06-28
     Ever Confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-06-28 10:36:29 UTC ---
Here's a C++03 version, which G++ also accepts but Clang and Comeau online
reject:

struct t { char c; };
struct f { char c[2]; };

template<int> struct Int { };

template<typename T>
struct has_static {
  template<typename X>
  static t check(X*, Int<sizeof(T::fun())>* = 0);
  static f check(...);

  static const bool value = sizeof(check((T*)(0))) == sizeof(t);
};

struct test { int fun() { return 0; } };

bool b = has_static<test>::value;

G++ does reject it for different invalid expressions, e.g. if fun doesn't exist
at all, so it does seem to be treating the decltype expression as outside the
immediate context during type deduction, but not consistently.



More information about the Gcc-bugs mailing list