[LLVMbugs] [Bug 13286] New: invalid expressions in noexcept clauses do not cause substitution failure

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 6 12:29:56 PDT 2012


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

             Bug #: 13286
           Summary: invalid expressions in noexcept clauses do not cause
                    substitution failure
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: eric at boostpro.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I believe the following code should compile:

    #include <utility>

    struct S
    {
        void operator()(S) const {}
    };

    template<typename T>
    void foo(T) noexcept(noexcept(std::declval<S>()(std::declval<T>()))) {}

    void foo(...) {}

    int main()
    {
        foo(1);
    }

Clang rejects this, causing a hard error for the noexcept clause. I
think this is covered by the new SFINAE rules:

14.9.2/8:
> -- If a substitution results in an invalid type or expression, type 
> deduction fails. An invalid type or expression is one that would be
> ill-formed if written using the substituted arguments. Access
> checking is not done as part of the substitution process.
> Consequently, when deduction succeeds, an access error could still
> result when the function is instantiated. Only invalid types and
> expressions in the immediate context of the function type and its
> template parameter types can result in a deduction failure.

The way I read this, invalid expressions in noexcept classes should
cause substitution failure, and that would be consistent with how
invalid expressions are treated in decltype expressions appearing in the
function signature. That would mean clang is wrong and the code should compile.
I confess, I'm not 100% sure though.

-- 
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