[Bug c++/85679] New: __is_trivially_copyable returns false with volatile scalar type

flast at flast dot jp gcc-bugzilla@gcc.gnu.org
Mon May 7 12:23:00 GMT 2018


            Bug ID: 85679
           Summary: __is_trivially_copyable returns false with volatile
                    scalar type
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: flast at flast dot jp
  Target Milestone: ---

__is_trivially_copyable builtin returns true on volatile-qualified trivially
copyable class, or array of the class as expected. But not for
volatile-qualified scalar type, such as `int volatile`.

n4741 6.7 [basic.types] p.9 says:
> Cv-unqualified scalar types, trivially copyable class types (Clause 12),
> arrays of such types, and cv-qualified versions of these types are collectively
> called trivially copyable types.

i.e. following code should be compiled.
struct S{};
static_assert(__is_trivially_copyable(S volatile));
static_assert(__is_trivially_copyable(S volatile[]));
static_assert(__is_trivially_copyable(S const volatile));
static_assert(__is_trivially_copyable(S const volatile[]));

static_assert(__is_trivially_copyable(int volatile));
static_assert(__is_trivially_copyable(int volatile[]));
static_assert(__is_trivially_copyable(int const volatile));
static_assert(__is_trivially_copyable(int const volatile[]));

See also:
- http://wg21.link/cwg496
- http://wg21.link/cwg1746
- http://wg21.link/cwg2094

More information about the Gcc-bugs mailing list