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

            Bug ID: 23812
           Summary: Single-element initializer_list invokes wrong
                    constructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Test case:

#include <initializer_list>
#include <iostream>

struct Q {
    Q() { std::cout << "default\n"; }
    Q(Q const&) { std::cout << "copy\n"; }
    Q(Q&&) { std::cout << "move\n"; }
    Q(std::initializer_list<Q>) { std::cout << "initializer list\n"; }
};

int main() {
    Q x = Q { Q() };
}

"Q { Q() }" should invoke the initializer_list constructor, but recent Clang
(trunk as of today, r239482) treats it as a move instead. For comparison, clang
3.6 and older, gcc 4.9, 5.1, and MSVC2015 all select the initializer_list
constructor.

This is really bad for us, as it silently changes the meaning of code in a
subtle way (manifests as making our JSON library elide single-element array
literals). :(

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to