public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46162] New: Invalid SFINAE with static member function/variable
@ 2010-10-25 2:32 greg.r.rogers at gmail dot com
2010-10-26 9:13 ` [Bug c++/46162] " paolo.carlini at oracle dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: greg.r.rogers at gmail dot com @ 2010-10-25 2:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46162
Summary: Invalid SFINAE with static member function/variable
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: greg.r.rogers@gmail.com
gcc rejects the following valid code, which compiles under clang, Comeau, and
MSVC++. Expected output is "0 0". I am using gcc 4.5.1, I have not tried it on
older versions.
grogers@gazelle ~/junk $ cat junk.cpp
#include <iostream>
struct small_type { char dummy; };
struct large_type { char dummy[2]; };
template<class T>
struct has_foo_member_variable
{
template<int T::*> struct tester;
template<class U> static small_type has_foo(tester<&U::foo> *);
template<class U> static large_type has_foo(...);
static const bool value = (sizeof(has_foo<T>(0)) == sizeof(small_type));
};
struct A
{
static int foo()
{
return 0;
}
};
struct B
{
static int foo;
};
int main()
{
std::cout << has_foo_member_variable<A>::value << ' '
<< has_foo_member_variable<B>::value << '\n';
}
grogers@gazelle ~/junk $ g++ junk.cpp
junk.cpp: In instantiation of ‘const bool has_foo_member_variable<A>::value’:
junk.cpp:30:46: instantiated from here
junk.cpp:12:75: error: ‘A::foo’ is not a valid template argument for type ‘int
A::*’
junk.cpp:12:75: error: it must be a pointer-to-member of the form `&X::Y'
junk.cpp: In instantiation of ‘const bool has_foo_member_variable<B>::value’:
junk.cpp:31:40: instantiated from here
junk.cpp:12:75: error: ‘& B::foo’ is not a valid template argument for type
‘int B::*’
junk.cpp:12:75: error: it must be a pointer-to-member of the form `&X::Y'
grogers@gazelle ~/junk $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/usr
--enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-gnu-unique-object --enable-lto --enable-plugin --disable-multilib
--disable-libstdcxx-pch --with-system-zlib --with-ppl --with-cloog
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info
Thread model: posix
gcc version 4.5.1 (GCC)
grogers@gazelle ~/junk $ uname -a
Linux gazelle 2.6.35-ARCH #1 SMP PREEMPT Fri Aug 27 16:22:18 UTC 2010 i686 AMD
Phenom(tm) 9950 Quad-Core Processor AuthenticAMD GNU/Linux
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-02 12:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-25 2:32 [Bug c++/46162] New: Invalid SFINAE with static member function/variable greg.r.rogers at gmail dot com
2010-10-26 9:13 ` [Bug c++/46162] " paolo.carlini at oracle dot com
2010-10-28 14:48 ` dodji at gcc dot gnu.org
2010-11-02 12:59 ` dodji at gcc dot gnu.org
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).