* rtti.c (tinfo_name): Fix lengths for private case.
From-SVN: r153789
This commit is contained in:
parent
691a1b27dc
commit
c86f25e8ea
|
@ -1,3 +1,7 @@
|
|||
2009-10-31 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* rtti.c (tinfo_name): Fix lengths for private case.
|
||||
|
||||
2009-10-31 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/41754
|
||||
|
|
|
@ -364,10 +364,10 @@ tinfo_name (tree type, bool mark_private)
|
|||
if (mark_private)
|
||||
{
|
||||
/* Inject '*' at beginning of name to force pointer comparison. */
|
||||
char* buf = (char*) XALLOCAVEC (char, length + 1);
|
||||
char* buf = (char*) XALLOCAVEC (char, length + 2);
|
||||
buf[0] = '*';
|
||||
memcpy (buf + 1, name, length);
|
||||
name_string = build_string (length + 1, buf);
|
||||
memcpy (buf + 1, name, length + 1);
|
||||
name_string = build_string (length + 2, buf);
|
||||
}
|
||||
else
|
||||
name_string = build_string (length + 1, name);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
2009-10-31 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* g++.dg/rtti/typeid9.C: New.
|
||||
|
||||
PR c++/41754
|
||||
* g++.dg/cpp0x/initlist25.C: New.
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// Test that the typeid name for a local class is properly null-terminated.
|
||||
// { dg-do run }
|
||||
|
||||
#include <string.h>
|
||||
#include <typeinfo>
|
||||
#include <stdio.h>
|
||||
|
||||
int f()
|
||||
{
|
||||
struct A {}; struct B {};
|
||||
const std::type_info &ti = typeid(A);
|
||||
const std::type_info &ti2 = typeid(B);
|
||||
puts (ti.name());
|
||||
puts (ti2.name());
|
||||
return strcmp (ti.name(), "Z1fvE1A") || strcmp (ti2.name(), "Z1fvE1B");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
return f();
|
||||
}
|
Loading…
Reference in New Issue