public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53788] New: C++11 decltype sfinae static member function check (4.7.1)
@ 2012-06-27 18:43 exa7z at live dot com
  2012-06-27 22:30 ` [Bug c++/53788] " daniel.kruegler at googlemail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: exa7z at live dot com @ 2012-06-27 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53788
           Summary: C++11 decltype sfinae static member function check
                    (4.7.1)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: exa7z@live.com


Greetings all. The following code should *not* compile (one of the ways for
detecting the presence or not of a static member function), because of a typo I
did in T/X substitution in the check function template:

Here is the testcase:
/* BEGIN TESTCASE */

#include <cstdio>
#include <type_traits>

template<typename T>
struct has_static {

    // NOTICE THE T/X substitution error, T::fun() should have been X::fun()
    // thanks to dgregor in http://llvm.org/bugs/show_bug.cgi?id=13223
    template<typename X>
    static std::true_type check(X*, decltype(T::fun())* = 0);

    static std::false_type check(...);

    typedef decltype(check((T*)(0))) _tmp;

    static const bool value = _tmp::value;
};

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

int main() {
    printf("%d\n", has_static<test>::value);
    return(0);
}
/* END TESTCASE */

used: g++ (GCC) 4.7.1 with --std=c++0x

According to dgregor's reply in the aforementioned llvm bugzilla entry, clang
is right to not compile this while g++ tacitly accepts it before its time (from
4.5.1 to 4.7.1 at least). Is this something requiring fixing?

thanks.


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

end of thread, other threads:[~2012-07-03  3:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 18:43 [Bug c++/53788] New: C++11 decltype sfinae static member function check (4.7.1) exa7z at live dot com
2012-06-27 22:30 ` [Bug c++/53788] " daniel.kruegler at googlemail dot com
2012-06-28  9:45 ` redi at gcc dot gnu.org
2012-06-28 10:36 ` redi at gcc dot gnu.org
2012-06-28 17:37 ` exa7z at live dot com
2012-06-28 17:43 ` exa7z at live dot com
2012-07-02 21:05 ` jason at gcc dot gnu.org
2012-07-03  3:30 ` jason at gcc dot gnu.org
2012-07-03  3:31 ` jason 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).