diff mbox

Add testcase for PR59250

Message ID 20131125110244.GO30062@redhat.com
State New
Headers show

Commit Message

Marek Polacek Nov. 25, 2013, 11:02 a.m. UTC
On Mon, Nov 25, 2013 at 11:47:29AM +0100, Jakub Jelinek wrote:
> 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.

It is reproduceable with all three variants.  I'll commit this one shortly.
 
> Note, once the LTO issues with internal functions are fixed, we need
> to grep for all those dg-skip-if and remove them.

Yeah, definitely.  I'm keeping it in mind.

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

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


	Marek

Comments

Richard Biener Nov. 26, 2013, 9:13 a.m. UTC | #1
On Mon, Nov 25, 2013 at 12:02 PM, Marek Polacek <polacek@redhat.com> wrote:
> On Mon, Nov 25, 2013 at 11:47:29AM +0100, Jakub Jelinek wrote:
>> 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.
>
> It is reproduceable with all three variants.  I'll commit this one shortly.
>
>> Note, once the LTO issues with internal functions are fixed, we need
>> to grep for all those dg-skip-if and remove them.
>
> Yeah, definitely.  I'm keeping it in mind.

I'll pre-approve removing the assert for ->leaf that currently makes
internal fns ICE with LTO for now.  If it makes them "work" (please
double-check also code generation results).

I'll coordinate with Honza on who is going to fix this for real.

Richard.

> 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:55:37.000000000 +0100
> @@ -0,0 +1,19 @@
> +// PR sanitizer/59250
> +// { dg-do compile }
> +// { dg-options "-fsanitize=undefined" }
> +// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
> +
> +struct E {
> + int i;
> +};
> +
> +struct S {
> +  const char *s;
> +  S (const char *);
> +  static E *e;
> +};
> +
> +S::S (const char *) : s (0)
> +{
> +  e = new E ();
> +}
>
>         Marek
Marek Polacek Nov. 26, 2013, 9:24 a.m. UTC | #2
On Tue, Nov 26, 2013 at 10:13:35AM +0100, Richard Biener wrote:
> On Mon, Nov 25, 2013 at 12:02 PM, Marek Polacek <polacek@redhat.com> wrote:
> > On Mon, Nov 25, 2013 at 11:47:29AM +0100, Jakub Jelinek wrote:
> >> 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.
> >
> > It is reproduceable with all three variants.  I'll commit this one shortly.
> >
> >> Note, once the LTO issues with internal functions are fixed, we need
> >> to grep for all those dg-skip-if and remove them.
> >
> > Yeah, definitely.  I'm keeping it in mind.
> 
> I'll pre-approve removing the assert for ->leaf that currently makes
> internal fns ICE with LTO for now.  If it makes them "work" (please
> double-check also code generation results).

Unfortunately, only removing the assert for ->leaf does not work,
without it I get:
./a.out
[Leaving LTRANS /tmp/ccvr1cAT.args]
[Leaving LTRANS /tmp/ccfdPwKs.ltrans.out]
[Leaving LTRANS /tmp/cctcbfzL.args]
[Leaving LTRANS /tmp/ccfdPwKs.ltrans0.o]
/tmp/ccfdPwKs.ltrans0.ltrans.o: In function `main':
ccfdPwKs.ltrans0.o:(.text+0x1d): undefined reference to `.Lubsan_data0.2659'

(Though it may be a bug in ubsan.)
 
	Marek
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:55:37.000000000 +0100
@@ -0,0 +1,19 @@ 
+// PR sanitizer/59250
+// { dg-do compile }
+// { dg-options "-fsanitize=undefined" }
+// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
+
+struct E {
+ int i;
+};
+
+struct S {
+  const char *s;
+  S (const char *);
+  static E *e;
+};
+
+S::S (const char *) : s (0)
+{
+  e = new E ();
+}