[Bug c++/39188] G++ doesn't handle static anonymous union right
hjl dot tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Feb 14 00:38:00 GMT 2009
------- Comment #1 from hjl dot tools at gmail dot com 2009-02-14 00:38 -------
[hjl@gnu-6 936]$ cat x.cc
#include "foo.h"
int *
x (void)
{
return f ();
}
[hjl@gnu-6 936]$ cat y.cc
#include <stdio.h>
#include "foo.h"
extern int *x (void);
int
main ()
{
printf ("%p, %p\n", x (), f ());
return 0;
}
[hjl@gnu-6 936]$ cat foo.h
inline int *
f ()
{
static union
{
const char *p;
int i;
};
return &i;
}
[hjl@gnu-6 936]$ g++ x.cc y.cc -O2
[hjl@gnu-6 936]$ ./a.out
0x600a38, 0x600a40
[hjl@gnu-6 936]$ nm x.o | c++filt
0000000000000000 W f()
0000000000000000 T x()
0000000000000000 b f()::p
U __gxx_personality_v0
f()::p should be global and linkonce.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39188
More information about the Gcc-bugs
mailing list