[haiku-bugs] [Haiku] #6322: [gcc] Static class field in shared object links to two addresses

  • From: "Adek336" <trac@xxxxxxxxxxxx>
  • Date: Fri, 16 Jul 2010 07:18:54 -0000

#6322: [gcc] Static class field in shared object links to two addresses
-------------------------+--------------------------------------------------
   Reporter:  Adek336    |        Owner:  nobody   
       Type:  bug        |       Status:  new      
   Priority:  normal     |    Milestone:  R1       
  Component:  - General  |      Version:  R1/alpha2
   Keywords:             |   Blocked By:           
Has a Patch:  0          |     Platform:  All      
   Blocking:             |  
-------------------------+--------------------------------------------------
 {{{

 /* A.h */
 #ifndef A_H
 #define A_H

 #include <iostream>

 class A
 {
 public:
     A()
     {
         static int i = 0;
         std::cerr << (void*)&i << std::endl;
     }
 };

 #endif
 }}}

 {{{
 /* x.cc */
 #include "A.h"

 A x;

 int main()
 {
 }
 }}}

 {{{
 /* y.cc */
 #include "A.h"

 A y;
 }}}

 {{{
 g++ y.cc -shared -o y.so
 g++ x.cc y.so
 LIBRARY_PATH=. ./a.out
 }}}

 results in
 {{{
 0x203ac0
 0x201d1c
 }}}

 whereas the addresses should be equal.

 r37527, gcc4+2 hybrid, VBox 3.1

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/6322>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: