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

            Bug ID: 15757
           Summary: Mysterious error with inheriting constructor,
                    delegating constructor, and noexcept specifier
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

This is as far as I've been able to narrow this problem down. It seems to be
some strange confluence of C++11 features that is causing the perfect storm:

{{{
    struct S
    {};

    template<typename X, typename Y>
    struct T
    {
        template<typename A>
        T(X x, A &&a)
        {}

        template<typename A>
        explicit T(A &&a)
            noexcept(noexcept(
                T(X(), static_cast<A &&>(a))
            ))
          : T(X(), static_cast<A &&>(a))
        {}
    };

    template<typename X, typename Y>
    struct U
      : T<X, Y>
    {
        using T<X, Y>::T;
    };

    // Comment this function out and everything works
    U<S, char> foo(char ch)
    {
        return U<S, char>(ch);
    }

    int main()
    {
        U<S, int>  a(42);   // This works
        U<S, char> b('4');  // This fails
    }
}}}

The error I'm getting is:

1>  "C:/cygwin/usr/local/bin/clang++.exe" -c -O0 -std=gnu++11 main.cpp -o
main.o
1>  main.cpp:14:20: error: cannot cast from lvalue of type 'char' to rvalue
reference type 'S &&'; types are not compatible
1>              T(X(), static_cast<A &&>(a))
1>                     ^~~~~~~~~~~~~~~~~~~~
1>  main.cpp:24:20: note: in instantiation of exception specification for
'T<char>' requested here
1>      using T<X, Y>::T;
1>                     ^
1>  main.cpp:36:16: note: inheriting constructor for 'U<S, char>' first
required here
1>      U<S, char> b('4');  // This fails
1>                 ^
1>  1 error generated.

I can't make any sense of the error message. Seemingly innocuous changes to the
code, like commenting out the foo function or the noexcept clause, make the
error go away.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to