https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67557

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
   Last reconfirmed|                            |2015-09-14
         Resolution|INVALID                     |---
     Ever confirmed|0                           |1

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
There's nothing invalid about the program, no member function is called on the
object being constructed (except the constructor, but obviously you have to
call a constructor before the object is constructed!)

After x has been constructed its string member has an invalid pointer:

(gdb) p/r  x.tag_
$1 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>>
= {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
_M_p = 0x7fffffffd380 ""}, _M_string_length = 0, {
    _M_local_buf = "\000\001\241Y9\000\000\000Щ\304\367\377\177\000",
_M_allocated_capacity = 246316859648}}
(gdb) p x.tag_._M_local_buf + 0
$2 = 0x7fffffffd3f0 ""

(gdb) p x.tag_._M_dataplus._M_p
$3 = (std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::pointer) 0x7fffffffd380 ""


N.B. 0x7fffffffd380 != 0x7fffffffd3f0

The code works correctly with -fno-elide-constructors

Reply via email to