[LLVMbugs] [Bug 13733] New: Implicit copy assignment mistakenly marked noexcept

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 30 16:18:19 PDT 2012


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

             Bug #: 13733
           Summary: Implicit copy assignment mistakenly marked noexcept
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: hhinnant at apple.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This program fails to compile:

#include <iostream>

using namespace std;

struct annotate_t {
    annotate_t() { cout << "default-ctor" << endl; }
    ~annotate_t() { cout << "dtor" << endl; }
    annotate_t(const annotate_t&) noexcept(false) { cout << "copy-ctor" <<
endl; }
    annotate_t(annotate_t&&) noexcept { cout << "move-ctor" << endl; }

    // This is a pass-by-value assignment to avoid having to write it twice
    annotate_t& operator=(annotate_t) noexcept { cout << "assign" << endl;
return *this; }
};

// The implicit move assignment is deleted on this type
struct pair_t {
    int x_;
    annotate_t y_;
};

static_assert(!noexcept(declval<pair_t&>() = declval<const pair_t&>()), "");

int main() {
}


static_assert(!noexcept(declval<pair_t&>() = declval<const pair_t&>()), "");
^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

I would expect it to compile because the implicit copy assignment operator of
pair_t must call the noexcept(false) annotate_t copy constructor.

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