[llvm-bugs] [Bug 30551] New: Trailing return type accepted, even though it should be rejected

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 28 07:05:33 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30551

            Bug ID: 30551
           Summary: Trailing return type accepted, even though it should
                    be rejected
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: michele.caini at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The code below should be rejected, but clang accepts it:

    #include <type_traits>

    template<typename T>
    constexpr auto check(T &&t) -> decltype(typename std::integral_constant<T,
t>::type{}) { }

    int main() {  
        //check(42); // (1)
    }

I suspect the function definition should be rejected for it is ill-formed, t
cannot be used with std::integral_constant that way.
If you uncomment (1), the compilation fails with the right error:

> candidate template ignored: substitution failure [with T = int]: non-type template argument is not a constant expression

-- 
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/20160928/916559a4/attachment.html>


More information about the llvm-bugs mailing list