This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] target/68972 - g++.dg/cpp1y/vla-initlist1.C test case fails on powerpc64le
- From: Martin Sebor <msebor at gmail dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Jason Merrill <jason at redhat dot com>, seurer at linux dot vnet dot ibm dot com
- Date: Thu, 28 Jan 2016 12:48:49 -0700
- Subject: [PATCH] target/68972 - g++.dg/cpp1y/vla-initlist1.C test case fails on powerpc64le
- Authentication-results: sourceware.org; auth=none
The g++.dg/cpp1y/vla-initlist1.C test relies on undefined behavior
(reading an uninitialized array element) to verify that two VLAs
are allocated in memory starting at the same address. The test
has been seen to fail on powerpc64-*-linux-gnu and spu-*-elf.
The attached patch removes the undefined behavior while still
verifying the same thing. It passes on powerpc64le.
Jason, based on your comment in the bug I've removed the part
of the test that verifies that the no-op initializer-list ctor
for the user-defined VLA leaves the array elements uninitialized.
If that's something that should be tested let me know and I'll
add another test or test case for that.
Martin
2016-01-28 Martin Sebor <msebor@redhat.com>
target/68972
* g++.dg/cpp1y/vla-initlist1.C: Prevent test failure on powepc64le
by making the test less undefined.
diff --git a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C
index 8f5709d..339aacc 100644
--- a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C
+++ b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C
@@ -12,12 +12,21 @@ struct A
};
int x = 4;
-int main(int argc, char **argv)
+int main(int argc, char **)
{
- { int i[x] = { 42, 42, 42, 42 }; }
+ typedef __UINTPTR_TYPE__ uintptr_t;
+ uintptr_t vla1_addr, vla2_addr;
+
+ // Verify that both arrays are allocated at the same address.
+ {
+ int vla1[x] = { 42, 42, 42, 42 };
+ vla1_addr = reinterpret_cast<uintptr_t>(vla1);
+ }
{
- A a[x] = { argc };
- if (a[1].i != 42)
+ A vla2[x] = { argc };
+ vla2_addr = reinterpret_cast<uintptr_t>(vla2);
+
+ if (vla1_addr != vla2_addr)
__builtin_abort ();
}
}