This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/39188] G++ doesn't handle static anonymous union right
- From: "hjl dot tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Feb 2009 00:38:23 -0000
- Subject: [Bug c++/39188] G++ doesn't handle static anonymous union right
- References: <bug-39188-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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