[LLVMbugs] [Bug 23812] New: Single-element initializer_list invokes wrong constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 10 12:55:46 PDT 2015


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: unassignedclangbugs at nondot.org
          Reporter: j4cbo at dropbox.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150610/c4fdb677/attachment.html>


More information about the llvm-bugs mailing list