[LLVMbugs] [Bug 10035] New: noexcept can't reference function arguments

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 27 08:04:30 PDT 2011


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

           Summary: noexcept can't reference function arguments
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: hhinnant at apple.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Apple clang version 3.0 (trunk 131788) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin10.7.0
Thread model: posix

Here is a minimal test case:


template <class T>
struct some_trait
{
    static const bool value = true;
};

template <class T>
void
swap(T& x, T& y) noexcept(some_trait<T>::value);

template <class ForwardIterator1, class ForwardIterator2>
inline
void
iter_swap(ForwardIterator1 a, ForwardIterator2 b)
                                                noexcept(noexcept(swap(*a,
*b)))
{
    swap(*a, *b);
}

int main()
{
    int i = 0, j = 0;
    iter_swap(&i, &j);
}


test.cpp:16:73: error: reference to local variable 'a' declared in enclosed
function 'iter_swap'
                                                noexcept(noexcept(swap(*a,
*b)))
                                                                        ^
test.cpp:15:1: note: in instantiation of function template specialization
'iter_swap<int *, int *>' requested here
iter_swap(ForwardIterator1 a, ForwardIterator2 b)
^
test.cpp:15:28: note: 'a' declared here
iter_swap(ForwardIterator1 a, ForwardIterator2 b)
                           ^
1 error generated.

The expectation is for this to compile because 'a' and 'b' are in scope.

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