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++/34121] wrong this pointer passed to constructor of temporary object



------- Comment #4 from gcc-bugzilla at contacts dot eelis dot net  2008-08-21 12:51 -------
Isolated and reproduced with GCC 4.4 on x86_64:

  #include <iostream>
  #include <stdint.h>

  struct A
  {
    uint64_t p;
    char m_ac[18];

    A() { std::cout << "default constructed at " << this << '\n'; }
    ~A() { std::cout << "destructed at " << this << '\n'; }

    A(A const &) { std::cout << "copy constructed at " << this << '\n'; }
  };

  A f() { return A(); }

  struct B: A { B(): A(f()) {} };

  int main() { B b; }

Output:

  default constructed at 0x7fffd583ca40
  destructed at 0x7fffd583ca90

These two addresses really should be the same.


-- 

gcc-bugzilla at contacts dot eelis dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc-bugzilla at contacts dot
                   |                            |eelis dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34121


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