From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23362 invoked by alias); 9 Dec 2013 08:46:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23342 invoked by uid 48); 9 Dec 2013 08:46:16 -0000 From: "temporal at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59426] New: __has_trivial_{copy/assign} behavior differs from documentation Date: Mon, 09 Dec 2013 08:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: temporal at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg00684.txt.bz2 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 )