I didn't make the change conditional for C++14 or any other version. Volatile
scalars weren't memcpyable anyway, so I thought that this should just
apply to all standard versions we support. Tested on Linux-x64.
/cp
2014-11-20 Ville Voutilainen <[email protected]>
PR c++/63959
* tree.c (trivially_copyable_p): Check for CP_TYPE_VOLATILE_P.
/testsuite
2014-11-20 Ville Voutilainen <[email protected]>
PR c++/63959
* g++.dg/ext/is_trivially_constructible1.C: Add tests for int and
volatile int.
../libstdc++-v3/testsuite/
2014-11-20 Ville Voutilainen <[email protected]>
PR c++/63959
* 20_util/is_trivially_copyable/value.cc: Add test for volatile int.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 4502273..f8506f5 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3206,7 +3206,7 @@ trivially_copyable_p (const_tree t)
&& !TYPE_HAS_COMPLEX_MOVE_ASSIGN (t)
&& TYPE_HAS_TRIVIAL_DESTRUCTOR (t));
else
- return scalarish_type_p (t);
+ return !CP_TYPE_VOLATILE_P (t) && scalarish_type_p (t);
}
/* Returns 1 iff type T is a trivial type, as defined in [basic.types] and
diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
index f558538..c866373 100644
--- a/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
+++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C
@@ -33,3 +33,6 @@ SA(__is_trivially_constructible(int,double));
SA(!__is_trivially_constructible(int,B));
SA(!__is_trivially_constructible(D));
+
+SA(__is_trivially_copyable(int));
+SA(!__is_trivially_copyable(volatile int));
diff --git a/libstdc++-v3/testsuite/20_util/is_trivially_copyable/value.cc
b/libstdc++-v3/testsuite/20_util/is_trivially_copyable/value.cc
index c21a5c4..c861355 100644
--- a/libstdc++-v3/testsuite/20_util/is_trivially_copyable/value.cc
+++ b/libstdc++-v3/testsuite/20_util/is_trivially_copyable/value.cc
@@ -47,6 +47,8 @@ void test01()
static_assert(test_property<is_trivially_copyable,
int>(true), "");
+ static_assert(test_property<is_trivially_copyable,
+ volatile int>(false), "");
static_assert(test_property<is_trivially_copyable,
TType>(true), "");
static_assert(test_property<is_trivially_copyable,