http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58074

            Bug ID: 58074
           Summary: [C++11] __is_trivial intrinsic fails for deleted
                    members and for non-trivial copy-c'tors
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.kruegler at googlemail dot com

The following observations where originally found by testing the
std::is_trivial trait from <type_traits>, but the actual problem seems to
result from the __is_trivial intrinsic, therefore I created a non-library issue
from this.

gcc 4.9.0 20130616 (experimental) when compiled with the flags

-std=c++11 -Wall -pedantic

rejects the following code:

//-----------------------------
struct Trivial
{
  Trivial() = delete;
};

struct NonTrivial
{
  NonTrivial() = default;
  NonTrivial(NonTrivial&) = default;
  NonTrivial& operator=(NonTrivial&) = default;
};

static_assert(__is_trivial(Trivial), "Ouch");
static_assert(!__is_trivial(NonTrivial), "Ouch");
//-----------------------------

"
main.cpp|13|error: static assertion failed: Ouch|
main.cpp|14|error: static assertion failed: Ouch|
"

The first test should be valid, because 12.1 p4 says 

"A default constructor is trivial if it is **not user-provided** and if [..]" 

and according to 8.4.2 p4 

"A function is user-provided if it is user-declared and **not explicitly
defaulted or deleted** on its first declaration.". 

The deleted default constructor should not prevent type Trivial of being
trivial (Maybe this part of the problem is related to bug 52707, but I'm not
sure).

The second test should succeed, because according to 12.8 p12:

"A copy/move constructor for class X is trivial if it is not user-provided,
**its declared parameter type is the same as if it had been implicitly
declared**, and if [..]"

and 12.8 p25, respectively:

"A copy/move assignment operator for class X is trivial if it is not
user-provided, **its declared parameter type is the same as if it had been
implicitly declared**, and if [..]"

The copy-constructor/assignment operator of NonTrivial do both not have the
parameter type (according to the definition of function parameter types as of
8.3.5) as if it had been implicitly declared.

Reply via email to