[LLVMbugs] [Bug 13223] New: C++11 decltype sfinae static member function check

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 27 09:42:50 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13223

             Bug #: 13223
           Summary: C++11 decltype sfinae static member function check
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: exa7z at live.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8781
  --> http://llvm.org/bugs/attachment.cgi?id=8781
sfinae check code segment

Greetings all. The following code should compile due to SFINAE resolution (a
method for detecting the presence or not of a static member function), but it
does not, here is the clang version used:

clang version 3.2 (trunk 159265)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Here is the testcase:
/* BEGIN TESTCASE */

#include <cstdio>
#include <type_traits>

template<typename T>
struct has_static {
    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 */

And here is the error clang gives:
=================================

static_sfinae.cc:7:46: error: call to non-static member function without an
object argument
    static std::true_type check(X*, decltype(T::fun())* = 0);
                                             ^~~~~~
static_sfinae.cc:21:20: note: in instantiation of template class
'has_static<test>' requested here                                    
    printf("%d\n", has_static<test>::value);
                   ^
1 error generated.

=================================

Take note ideone's pastebin (gcc 4.5.1 in C++0x mode) compiles and runs this
without problems:

http://ideone.com/0LigN

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list