aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2015-11-26 23:31:32 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2015-11-26 16:31:32 -0700
commited48be0ef388933901f5785e2c3dbf83c39242ad (patch)
tree347e0d0d3d5a1298a2703b2bf8f5358f098f4032
parent1e5d7fd638ca44b45e9d1a49da0b39e6d0cb1fc7 (diff)
downloadgcc-ed48be0ef388933901f5785e2c3dbf83c39242ad.zip
gcc-ed48be0ef388933901f5785e2c3dbf83c39242ad.tar.gz
gcc-ed48be0ef388933901f5785e2c3dbf83c39242ad.tar.bz2
Correctly handle ARM targets.
* g++.dg/init/new45.C (cookie_size): New constant set to a value appropriate for the target. (operator new[]): Use it. From-SVN: r230987
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/init/new45.C16
2 files changed, 20 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d84b6a8..33ef41f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-11-26 Martin Sebor <msebor@redhat.com>
+
+ * g++.dg/init/new45.C (cookie_size): New constant set to a value
+ appropriate for the target.
+ (operator new[]): Use it.
+
2015-11-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67238
diff --git a/gcc/testsuite/g++.dg/init/new45.C b/gcc/testsuite/g++.dg/init/new45.C
index 92dac18..ff3bddb 100644
--- a/gcc/testsuite/g++.dg/init/new45.C
+++ b/gcc/testsuite/g++.dg/init/new45.C
@@ -23,13 +23,25 @@ struct POD {
enum { N = 123 };
+#if defined (__arm__) && defined (__ARM_EABI__)
+// On ARM EABI the cookie is always 8 bytes as per Section 3.2.2 of
+// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041d/IHI0041D_cppabi.pdf
+static const size_t cookie_size = 8;
+#else
+// On all other targets, the cookie size is the size of size_t
+// GCC, and ideally the C++ standard, should provide an API to
+// retrieve this constant.)
+static const size_t cookie_size = sizeof (size_t);
+#endif
+
inline __attribute__ ((always_inline))
void* operator new[] (size_t n)
{
// Verify that array new is invoked with an argument large enough
// for the array and a size_t cookie to store the number of elements.
// (This holds for classes with user-defined types but not POD types).
- if (n != N * sizeof (UDClass) + sizeof n) abort ();
+
+ if (n != N * sizeof (UDClass) + cookie_size) abort ();
return malloc (n);
}
@@ -60,7 +72,7 @@ void* operator new[] (size_t n, UDClass *p)
// Verify that placement array new overload for a class type with
// a user-defined ctor and dtor is invoked with an argument large
// enough for the array and a cookie.
- if (n != N * sizeof (UDClass) + sizeof n) abort ();
+ if (n != N * sizeof (UDClass) + cookie_size) abort ();
return p;
}