public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59426] New: __has_trivial_{copy/assign} behavior differs from documentation
@ 2013-12-09  8:46 temporal at gmail dot com
  2013-12-09 12:13 ` [Bug c++/59426] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: temporal at gmail dot com @ 2013-12-09  8:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59426
           Summary: __has_trivial_{copy/assign} behavior differs from
                    documentation
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: temporal at gmail dot com

Consider this struct with deleted copy/assignment:

struct S {
  S(const S&) = delete;
  S& operator=(const S&) = delete;
};

GCC's __has_trivial_{copy,assign}() intrinsics return false for this type. 
This is a useful answer, but appears to disagree with the documentation:

http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html

"__has_trivial_copy(type): If __is_pod (type) is true or type is a reference
type then the trait is true, else if type is a cv class or union type with a
trivial copy constructor ([class.copy]) then the trait is true, else it is
false. Requires: type shall be a complete type, (possibly cv-qualified) void,
or an array of unknown bound."

Technically, according to [class.copy], a deleted copy constructor is "trivial"
(because it is not user-provided, and none of the other exceptions apply).  A
similar argument applies to assignment.  Clang has chosen to implement these
intrinsics according to the docs rather than according to GCC's actual
behavior, and thus both return true for S.  To avoid confusion, GCC should
update either its documentation or its implementation so that the two match.

Apparently, other compilers (Embarcadero, MSVC) implement these intrinsics as
well.  I do not have access to them to test their behavior in this case.

(I originally filed a bug against Clang: 
http://llvm.org/bugs/show_bug.cgi?id=18185 )


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

end of thread, other threads:[~2022-03-28 19:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-09  8:46 [Bug c++/59426] New: __has_trivial_{copy/assign} behavior differs from documentation temporal at gmail dot com
2013-12-09 12:13 ` [Bug c++/59426] " paolo.carlini at oracle dot com
2013-12-09 21:05 ` richard-gccbugzilla at metafoo dot co.uk
2013-12-09 23:35 ` paolo.carlini at oracle dot com
2022-03-28 19:36 ` cvs-commit at gcc dot gnu.org
2022-03-28 19:37 ` jason 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).