re PR sanitizer/60569 (Segfault with -flto and -fsanitize=undefined)

PR sanitizer/60569
	* ubsan.c (ubsan_type_descriptor): Check that DECL_NAME is nonnull
	before accessing it.
testsuite/
	* g++.dg/ubsan/pr60569.C: New test.

From-SVN: r208681
This commit is contained in:
Marek Polacek 2014-03-19 12:25:04 +00:00 committed by Marek Polacek
parent bd99727761
commit 6daa2d914b
4 changed files with 33 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2014-03-19 Marek Polacek <polacek@redhat.com>
PR sanitizer/60569
* ubsan.c (ubsan_type_descriptor): Check that DECL_NAME is nonnull
before accessing it.
2014-03-19 Richard Biener <rguenther@suse.de>
PR lto/59543

View File

@ -1,3 +1,8 @@
2014-03-19 Marek Polacek <polacek@redhat.com>
PR sanitizer/60569
* g++.dg/ubsan/pr60569.C: New test.
2014-03-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/tls/pr58595.c: Require tls_runtime instead of tls.

View File

@ -0,0 +1,21 @@
// PR sanitizer/60569
// { dg-do link }
// { dg-require-effective-target lto }
// { dg-options "-fsanitize=undefined -flto" }
struct A
{
void foo ();
struct
{
int i;
void bar () { i = 0; }
} s;
};
void A::foo () { s.bar (); }
int
main ()
{
}

View File

@ -318,7 +318,7 @@ ubsan_type_descriptor (tree type, bool want_pointer_type_p)
{
if (TREE_CODE (TYPE_NAME (type2)) == IDENTIFIER_NODE)
tname = IDENTIFIER_POINTER (TYPE_NAME (type2));
else
else if (DECL_NAME (TYPE_NAME (type2)) != NULL)
tname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type2)));
}