This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/39188] G++ doesn't handle static anonymous union right



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]