[LLVMbugs] [Bug 17813] New: Class without default constructor, but with destructor is not trivially constructible

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 5 05:02:18 PST 2013


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

            Bug ID: 17813
           Summary: Class without default constructor, but with destructor
                    is not trivially constructible
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jonathan.sauer at gmx.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code does not compile with clang r193986:

struct Foo {
    ~Foo();
};

static_assert(__is_trivially_constructible(Foo), "");
static_assert(__has_trivial_constructor(Foo), "");


This results in:

% ~/LLVM/build/Release+Asserts/bin/clang -c -std=c++11 clang.cpp                
clang.cpp:5:1: error: static_assert failed ""
static_assert(__is_trivially_constructible(Foo), "");
^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.


Removing the destructor makes the code compile.

This looks like an inconsistency between __is_trivially_constructible and
__has_trivial_constructor, the former of which are used by libc++'s
std::is_trivially_constructible type trait (the latter is only used if the
former is not available).

Also __is_trivially_constructible is influenced by the existence of a
destructor, despite §12.1p5 not mentioning destructors:

| A default constructor is trivial if it is not user-provided and if:
| — its class has no virtual functions (10.3) and no virtual base classes
|   (10.1), and
| — no non-static data member of its class has a brace-or-equal-initializer,
|   and
| — all the direct base classes of its class have trivial default constructors,
|   and
| — for all the non-static data members of its class that are of class type
|   (or array thereof), each such class has a trivial default constructor.

-- 
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/20131105/12802fdb/attachment.html>


More information about the llvm-bugs mailing list