[LLVMbugs] [Bug 15724] New: set: default construction does not work properly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 11 08:08:19 PDT 2013


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

            Bug ID: 15724
           Summary: set: default construction does not work properly
           Product: libc++
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: akim.demaille at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

In the following piece of code, if I understand correctly libc++'s own header
(the initial "Synopsis" section), there is:

    set()
        noexcept(
            is_nothrow_default_constructible<allocator_type>::value &&
            is_nothrow_default_constructible<key_compare>::value &&
            is_nothrow_copy_constructible<key_compare>::value);
    explicit set(const value_compare& comp);

i.e., the default constructor is not flagged with explicit.

Yet, the following piece of code does not work, because there is no default
constructor: its functionality is provided by the following (explicit)
unary-constructor whose argument is optional.  So clang rejects the following
piece of code.

$ cat /tmp/set.cc
#include <set>
int
main()
{
  std::set<int> s = {};
}
$ clang++-mp-3.3 -std=c++11 -Wall /tmp/set.cc -stdlib=libc++
/tmp/set.cc:5:17: error: chosen constructor is explicit in copy-initialization
  std::set<int> s = {};
                ^   ~~
/opt/local/libexec/llvm-3.3/bin/../lib/c++/v1/set:378:14: note: constructor
declared here
    explicit set(const value_compare& __comp = value_compare())
             ^
1 error generated.
$ g++-mp-4.8 -std=c++11 -Wall /tmp/set.cc

-- 
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/20130411/39d1578a/attachment.html>


More information about the llvm-bugs mailing list