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

* [Bug c++/46162] Invalid SFINAE with static member function/variable
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2010-10-26  9:13 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2010-10-26 09:13:45 UTC ---
Looks related to PR46170.


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

* [Bug c++/46162] Invalid SFINAE with static member function/variable
  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
  2 siblings, 0 replies; 4+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-10-28 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |dodji at gcc dot gnu.org
         Resolution|                            |DUPLICATE

--- Comment #2 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-10-28 14:48:09 UTC ---
This is a duplicate of PR c++/46170

*** This bug has been marked as a duplicate of bug 46170 ***


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

* [Bug c++/46162] Invalid SFINAE with static member function/variable
  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
  2 siblings, 0 replies; 4+ messages in thread
From: dodji at gcc dot gnu.org @ 2010-11-02 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Dodji Seketeli <dodji at gcc dot gnu.org> 2010-11-02 12:58:51 UTC ---
Author: dodji
Date: Tue Nov  2 12:58:48 2010
New Revision: 166181

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166181
Log:
Fix PR c++/46170, c++/46162

gcc/cp/ChangeLog:
    PR c++/46170
    PR c++/46162
    * pt.c (check_valid_ptrmem_cst_expr): Add a complain parameter to
    control diagnostic.
    (convert_nontype_argument, convert_nontype_argument): Pass the
    complain parameter down to check_valid_ptrmem_cst_expr.

gcc/testsuite/ChangeLog:
    PR c++/46170
    PR c++/46162
    * g++.dg/template/sfinae26.C: New test.
    * g++.dg/template/sfinae27.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/template/sfinae26.C
    trunk/gcc/testsuite/g++.dg/template/sfinae27.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


^ 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).