C++ PATCH for c++/85679 and CWG 2094 - volatile scalars are trivially copyable

Jason Merrill jason@redhat.com
Mon May 20 17:51:00 GMT 2019


On 5/19/19 5:44 PM, Marek Polacek wrote:
> CWG 2094 partially reverts CWG 496, which means that volatile-qualified scalars
> are, once again, trivially copyable; [basic.types] now says "Scalar types,
> trivially copyable class types, arrays of such types, and cv-qualified
> versions of these types are collectively called trivially copyable types."
> 
> This previously changed in c++/63959 and this patch pretty much just reverts it.
> 
> I'm CCing libstdc++ because a test in libstdc++ needed updating.
> 
> Links to aforementioned CWGs:
> <http://wg21.link/cwg496>
> <http://wg21.link/cwg2094>
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?  Not planning to backport
> this.
> 
> 2019-05-19  Marek Polacek  <polacek@redhat.com>
> 
> 	CWG 2094 - volatile scalars are trivially copyable.
> 	PR c++/85679
> 	* tree.c (trivially_copyable_p): Don't check CP_TYPE_VOLATILE_P for
> 	scalar types.
> 
> 	* g++.dg/ext/is_trivially_constructible1.C: Change the expected result
> 	for volatile int.
> 	* g++.dg/ext/is_trivially_copyable.C: New test.
> 
> 	* testsuite/20_util/is_trivially_copyable/value.cc: Change the expected
> 	result for volatile int.
> 
> diff --git gcc/gcc/cp/tree.c gcc/gcc/cp/tree.c
> index 8d7f7a2c3e7..821f2b79a67 100644
> --- gcc/gcc/cp/tree.c
> +++ gcc/gcc/cp/tree.c
> @@ -4098,7 +4098,8 @@ trivially_copyable_p (const_tree t)
>   	    && !TYPE_HAS_COMPLEX_MOVE_ASSIGN (t)
>   	    && TYPE_HAS_TRIVIAL_DESTRUCTOR (t));
>     else
> -    return !CP_TYPE_VOLATILE_P (t) && scalarish_type_p (t);
> +    /* CWG 2094 makes volatile-qualified scalars trivially copyable.  */

I'd add "again".

OK, thanks.

Jason



More information about the Libstdc++ mailing list