From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30688 invoked by alias); 25 Oct 2010 02:32:30 -0000 Received: (qmail 30677 invoked by uid 22791); 25 Oct 2010 02:32:30 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CX,TW_DC X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 25 Oct 2010 02:32:25 +0000 From: "greg.r.rogers at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/46162] New: Invalid SFINAE with static member function/variable X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: greg.r.rogers at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Mon, 25 Oct 2010 02:32:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg02054.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D46162 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, a= nd 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=20 #include struct small_type { char dummy; }; struct large_type { char dummy[2]; }; template struct has_foo_member_variable { template struct tester; template static small_type has_foo(tester<&U::foo> *); template static large_type has_foo(...); static const bool value =3D (sizeof(has_foo(0)) =3D=3D sizeof(small_= type)); }; struct A { static int foo() { return 0; } }; struct B { static int foo; }; int main() { std::cout << has_foo_member_variable::value << ' ' << has_foo_member_variable::value << '\n'; } grogers@gazelle ~/junk $ g++ junk.cpp=20 junk.cpp: In instantiation of =E2=80=98const bool has_foo_member_variable::value=E2=80=99: junk.cpp:30:46: instantiated from here junk.cpp:12:75: error: =E2=80=98A::foo=E2=80=99 is not a valid template arg= ument for type =E2=80=98int A::*=E2=80=99 junk.cpp:12:75: error: it must be a pointer-to-member of the form `&X::Y' junk.cpp: In instantiation of =E2=80=98const bool has_foo_member_variable::value=E2=80=99: junk.cpp:31:40: instantiated from here junk.cpp:12:75: error: =E2=80=98& B::foo=E2=80=99 is not a valid template a= rgument for type =E2=80=98int B::*=E2=80=99 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=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/lto-wrapper Target: i686-pc-linux-gnu Configured with: ../configure --prefix=3D/usr --enable-languages=3Dc,c++,fortran,objc,obj-c++,ada --enable-shared --enable-threads=3Dposix --enable-__cxa_atexit --enable-clocale=3Dgnu --enable-gnu-unique-object --enable-lto --enable-plugin --disable-multilib --disable-libstdcxx-pch --with-system-zlib --with-ppl --with-cloog --libdir=3D/usr/lib --libexecdir=3D/usr/lib --mandir=3D/usr/share/man --infodir=3D/usr/share/info Thread model: posix gcc version 4.5.1 (GCC)=20 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