diff mbox

Add testcase for PR59250

Message ID 20131125103637.GN30062@redhat.com
State New
Headers show

Commit Message

Marek Polacek Nov. 25, 2013, 10:36 a.m. UTC
On Mon, Nov 25, 2013 at 10:49:56AM +0100, Jakub Jelinek wrote:
> On Mon, Nov 25, 2013 at 10:44:57AM +0100, Marek Polacek wrote:
> > The PR was fixed by Jakub in r205283, this patch merely adds a
> > testcase for it.  Passed ubsan testsuite for -m32/-m64.
> > 
> > Ok for trunk?
> 
> Can't you reduce it at least a little bit more?
> Like I doubt __attribute__ ((__visibility__ ("default")))
> is needed to reproduce, I'd also think you could get rid of the namespaces,
> perhaps also const _Alloc& __a = _Alloc() argument?

Ok, I've played a little bit with it and reduced it down to the
following.  Ok now?

2013-11-25  Marek Polacek  <polacek@redhat.com>

testsuite/
	* g++.dg/ubsan/pr59250.C: New test.


	Marek

Comments

Jakub Jelinek Nov. 25, 2013, 10:47 a.m. UTC | #1
On Mon, Nov 25, 2013 at 11:36:37AM +0100, Marek Polacek wrote:
> On Mon, Nov 25, 2013 at 10:49:56AM +0100, Jakub Jelinek wrote:
> > On Mon, Nov 25, 2013 at 10:44:57AM +0100, Marek Polacek wrote:
> > > The PR was fixed by Jakub in r205283, this patch merely adds a
> > > testcase for it.  Passed ubsan testsuite for -m32/-m64.
> > > 
> > > Ok for trunk?
> > 
> > Can't you reduce it at least a little bit more?
> > Like I doubt __attribute__ ((__visibility__ ("default")))
> > is needed to reproduce, I'd also think you could get rid of the namespaces,
> > perhaps also const _Alloc& __a = _Alloc() argument?
> 
> Ok, I've played a little bit with it and reduced it down to the
> following.  Ok now?

That looks much better, I wonder if it would reproduce even if the result
is saved somewhere (either E *e; field in S with swapping of the two class
definitions, or global var or static data member static E *e; of S),
otherwise the new just allocates and throws away.  Ok with that change, or
if it makes the problem no longer reproduceable, ok as is.

Note, once the LTO issues with internal functions are fixed, we need
to grep for all those dg-skip-if and remove them.

> 2013-11-25  Marek Polacek  <polacek@redhat.com>
> 
> testsuite/
> 	* g++.dg/ubsan/pr59250.C: New test.
> 
> --- gcc/testsuite/g++.dg/ubsan/pr59250.C.mp3	2013-11-25 10:43:24.797315678 +0100
> +++ gcc/testsuite/g++.dg/ubsan/pr59250.C	2013-11-25 11:33:56.817539980 +0100
> @@ -0,0 +1,18 @@
> +// PR sanitizer/59250
> +// { dg-do compile }
> +// { dg-options "-fsanitize=undefined" }
> +// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
> +
> +struct S {
> +  const char *s;
> +  S (const char *);
> +};
> +
> +struct E {
> + int i;
> +};
> +
> +S::S (const char *) : s (0)
> +{
> +  new E ();
> +}

	Jakub
diff mbox

Patch

--- gcc/testsuite/g++.dg/ubsan/pr59250.C.mp3	2013-11-25 10:43:24.797315678 +0100
+++ gcc/testsuite/g++.dg/ubsan/pr59250.C	2013-11-25 11:33:56.817539980 +0100
@@ -0,0 +1,18 @@ 
+// PR sanitizer/59250
+// { dg-do compile }
+// { dg-options "-fsanitize=undefined" }
+// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
+
+struct S {
+  const char *s;
+  S (const char *);
+};
+
+struct E {
+ int i;
+};
+
+S::S (const char *) : s (0)
+{
+  new E ();
+}