public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
@ 2013-08-03 17:58 daniel.kruegler at googlemail dot com
  2013-08-03 18:12 ` [Bug c++/58074] " paolo.carlini at oracle dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-08-03 17:58 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/58074] [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
  2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
@ 2013-08-03 18:12 ` paolo.carlini at oracle dot com
  2013-12-09  9:34 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-03 18:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
... and the issue is one more level deeper, because __is_trivial just uses the
internal trivial_type_p. I mean, it should be pretty easy to construct
testcases not involving __is_trival at all but handled incorrectly: outside the
implementation of the intrinsics, the internal pod_type_p itself is,
predictably, std_layout_type_p && trivial_type_p and then anything depending on
POD-ness is sensitive.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/58074] [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
  2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
  2013-08-03 18:12 ` [Bug c++/58074] " paolo.carlini at oracle dot com
@ 2013-12-09  9:34 ` paolo.carlini at oracle dot com
  2015-06-09 20:51 ` richard-gccbugzilla at metafoo dot co.uk
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-12-09  9:34 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-12-09
     Ever confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
In mainline we made some progress, the first static_assert passes.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/58074] [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
  2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
  2013-08-03 18:12 ` [Bug c++/58074] " paolo.carlini at oracle dot com
  2013-12-09  9:34 ` paolo.carlini at oracle dot com
@ 2015-06-09 20:51 ` richard-gccbugzilla at metafoo dot co.uk
  2015-07-09  9:12 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: richard-gccbugzilla at metafoo dot co.uk @ 2015-06-09 20:51 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Smith <richard-gccbugzilla at metafoo dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |richard-gccbugzilla@metafoo
                   |                            |.co.uk

--- Comment #3 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
This bug results in GCC failing to follow the Itanium C++ ABI when passing such
types to/from functions; see llvm.org/PR23764 for a user complaint of
cross-vendor ABI incompatibility.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/58074] [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
  2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2015-06-09 20:51 ` richard-gccbugzilla at metafoo dot co.uk
@ 2015-07-09  9:12 ` paolo.carlini at oracle dot com
  2015-09-22 15:21 ` [Bug c++/58074] [C++11][DR 1333] " jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-07-09  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
CC-ing Jason about the ABI issue.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/58074] [C++11][DR 1333] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
  2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2015-07-09  9:12 ` paolo.carlini at oracle dot com
@ 2015-09-22 15:21 ` jason at gcc dot gnu.org
  2015-09-22 15:22 ` jason at gcc dot gnu.org
  2024-06-18 20:22 ` mpolacek at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-09-22 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 36369
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36369&action=edit
patch

But here's the fix if the committee reaffirms the DR.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/58074] [C++11][DR 1333] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
  2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2015-09-22 15:21 ` [Bug c++/58074] [C++11][DR 1333] " jason at gcc dot gnu.org
@ 2015-09-22 15:22 ` jason at gcc dot gnu.org
  2024-06-18 20:22 ` mpolacek at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-09-22 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 36370
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36370&action=edit
patch for GCC 5

And a patch to add a -Wabi warning to GCC 5.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/58074] [C++11][DR 1333] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors
  2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
                   ` (5 preceding siblings ...)
  2015-09-22 15:22 ` jason at gcc dot gnu.org
@ 2024-06-18 20:22 ` mpolacek at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-06-18 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #12 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I have a patch for the first assert (via bug 85723), and I think the second
assert should also be reversed; that is, I think we want to assert this:

```
struct Trivial
{
  Trivial() = delete;
};

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

static_assert(!__is_trivial(Trivial), "Ouch"); // #1
static_assert(__is_trivial(NonTrivial), "Ouch"); // #2
```

The reason for #1 is https://cplusplus.github.io/CWG/issues/1496.html.
The reason for #2 is https://cplusplus.github.io/CWG/issues/2171.html (after
the https://cplusplus.github.io/CWG/issues/1593.html adjustment).

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-06-18 20:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-03 17:58 [Bug c++/58074] New: [C++11] __is_trivial intrinsic fails for deleted members and for non-trivial copy-c'tors daniel.kruegler at googlemail dot com
2013-08-03 18:12 ` [Bug c++/58074] " paolo.carlini at oracle dot com
2013-12-09  9:34 ` paolo.carlini at oracle dot com
2015-06-09 20:51 ` richard-gccbugzilla at metafoo dot co.uk
2015-07-09  9:12 ` paolo.carlini at oracle dot com
2015-09-22 15:21 ` [Bug c++/58074] [C++11][DR 1333] " jason at gcc dot gnu.org
2015-09-22 15:22 ` jason at gcc dot gnu.org
2024-06-18 20:22 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).