This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] XFAIL anew?.C
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Paul Brook <paul at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 05 Apr 2004 15:52:14 -0700
- Subject: Re: [patch] XFAIL anew?.C
- Organization: CodeSourcery, LLC
- References: <200404052346.40750.paul@codesourcery.com>
Paul Brook wrote:
The tests g++.dg/expr/ane{1,2,3,4}.C are currently passing by chance on some
systems (malloc happens to return a zeroed block of memory).
The patch below fails reproducible on all targets, and XFAILS them until this
is fixed.
Also updates tests to use standard conventions for indicating success and
failure.
Ok?
Yes.
(But, is using abort() and exit(0) really part of our testsuite
standard? I thought using return 0/return 1 was perfectly acceptable.
The change is OK, anyhow; that's just a side issue.)
Thanks,
Paul
2004-04-05 Paul Brook <paul@codesourcery.com>
PR2123
* g++.gd/expr/anew1.C: XFAIL and make reproducible. Call abort on
failuse and exit(0) on success.
* g++.gd/expr/anew2.C: Ditto.
* g++.gd/expr/anew3.C: Ditto.
* g++.gd/expr/anew4.C: Ditto.
Index: anew1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/expr/anew1.C,v
retrieving revision 1.2
diff -u -p -r1.2 anew1.C
--- anew1.C 20 Jun 2003 00:33:58 -0000 1.2
+++ anew1.C 5 Apr 2004 22:45:07 -0000
@@ -1,12 +1,20 @@
-// { dg-do run }
+// { dg-do run { xfail *-*-* } }
+// XFAILed until PR2123 is fixed
// PR 11228: array operator new, with zero-initialization and a variable
sized array.
// Regression test for PR
// Author: Matt Austern <austern@apple.com>
+#include <new>
+#include <stdlib.h>
+#include <string.h>
+
int* allocate(int n)
{
- return new int[n]();
+ void *p;
+ p = malloc(n * sizeof (int));
+ memset (p, 0xff, n * sizeof(int));
+ return new (p) int[n]();
}
int main()
@@ -15,6 +23,6 @@ int main()
int* p = allocate(n);
for (int i = 0; i < n; ++i)
if (p[i] != 0)
- return 1;
- return 0;
+ abort ();
+ exit (0);
}
Index: anew2.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/expr/anew2.C,v
retrieving revision 1.2
diff -u -p -r1.2 anew2.C
--- anew2.C 20 Jun 2003 00:33:58 -0000 1.2
+++ anew2.C 5 Apr 2004 22:45:07 -0000
@@ -1,12 +1,20 @@
-// { dg-do run }
+// { dg-do run { xfail *-*-* } }
+// XFAILed until PR2123 is fixed
// PR 11228: array operator new, with zero-initialization and a variable
sized array.
// Regression test for PR
// Author: Matt Austern <austern@apple.com>
+#include <new>
+#include <stdlib.h>
+#include <string.h>
+
double* allocate(int n)
{
- return new double[n]();
+ void *p;
+ p = malloc(n * sizeof (double));
+ memset (p, 0xff, n * sizeof(double));
+ return new (p) double[n]();
}
int main()
@@ -15,6 +23,6 @@ int main()
double* p = allocate(n);
for (int i = 0; i < n; ++i)
if (p[i] != 0.0)
- return 1;
- return 0;
+ abort ();
+ exit (0);
}
Index: anew3.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/expr/anew3.C,v
retrieving revision 1.2
diff -u -p -r1.2 anew3.C
--- anew3.C 20 Jun 2003 00:33:58 -0000 1.2
+++ anew3.C 5 Apr 2004 22:45:07 -0000
@@ -1,8 +1,13 @@
-// { dg-do run }
+// { dg-do run { xfail *-*-* } }
+// XFAILed until PR2123 is fixed
// PR 11228: array operator new, with zero-initialization and a variable
sized array.
// Regression test for PR
// Author: Matt Austern <austern@apple.com>
+#include <new>
+#include <stdlib.h>
+#include <string.h>
+
struct X
{
int a;
@@ -11,7 +16,10 @@ struct X
X* allocate(int n)
{
- return new X[n]();
+ void *p;
+ p = malloc(n * sizeof (X));
+ memset (p, 0xff, n * sizeof(X));
+ return new (p) X[n]();
}
int main()
@@ -20,6 +28,6 @@ int main()
X* p = allocate(n);
for (int i = 0; i < n; ++i)
if (p[i].a != 0 || p[i].b != 0.0)
- return 1;
- return 0;
+ abort ();
+ exit (0);
}
Index: anew4.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/expr/anew4.C,v
retrieving revision 1.2
diff -u -p -r1.2 anew4.C
--- anew4.C 20 Jun 2003 00:33:58 -0000 1.2
+++ anew4.C 5 Apr 2004 22:45:07 -0000
@@ -1,8 +1,13 @@
-// { dg-do run }
+// { dg-do run { xfail *-*-* } }
+// XFAILed until PR2123 is fixed
// PR 11228: array operator new, with zero-initialization and a variable
sized array.
// Regression test for PR
// Author: Matt Austern <austern@apple.com>
+#include <new>
+#include <stdlib.h>
+#include <string.h>
+
struct B
{
B();
@@ -23,7 +28,10 @@ struct D : public B
D* allocate(int n)
{
- return new D[n]();
+ void *p;
+ p = malloc(n * sizeof (D));
+ memset (p, 0xff, n * sizeof(D));
+ return new (p) D[n]();
}
int main()
@@ -32,6 +40,6 @@ int main()
D* p = allocate(n);
for (int i = 0; i < n; ++i)
if (p[i].n != 137 || p[i].x != 0)
- return 1;
- return 0;
+ abort ();
+ exit (0);
}
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com