[LLVMbugs] [Bug 15757] New: Mysterious error with inheriting constructor, delegating constructor, and noexcept specifier

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 15 22:47:04 PDT 2013


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: unassignedclangbugs at nondot.org
          Reporter: eric at boostpro.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130416/55513d92/attachment.html>


More information about the llvm-bugs mailing list