public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/64632] runtime error: member call on address 0x0000004318a8 which does not point to an object of type 'ios_base'
Date: Mon, 19 Jan 2015 18:15:00 -0000	[thread overview]
Message-ID: <bug-64632-4-iJ655frIpU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64632-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This just does the same std::ios_base::_M_streambuf_state member directly
rather than through the basic_ios<char>::rdstate() member function (compile
with -fno-access-control)

#include <fstream>

int main()
{
  std::ofstream f;
  std::ios_base& base = f;
  return base._M_streambuf_state;
}

ub.cc:6:15: runtime error: member access within address 0x7fff3d4e47e8 which
does not point to an object of type 'ios_base'
0x7fff3d4e46f0: note: object is base class subobject at offset 248 within
object of type 'std::basic_ofstream<char, std::char_traits<char> >'
 00 00 00 00  f8 c2 37 36 c2 7f 00 00  40 c1 37 36 c2 7f 00 00  00 00 00 00 00
00 00 00  00 00 00 00
              ^ 

I don't see how this can possibly go wrong ... it just accesses a member of a
base class.  It makes no difference if you don't use the reference to base:

  std::ofstream f;
  return f._M_streambuf_state;

Or use a pointer instead of reference:

  std::ofstream f;
  std::ios_base* base = &f;
  return base->_M_streambuf_state;

I don't think this is a libstdc++ issue.


  parent reply	other threads:[~2015-01-19 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16 16:10 [Bug libstdc++/64632] New: " trippels at gcc dot gnu.org
2015-01-19 17:43 ` [Bug libstdc++/64632] " burnus at gcc dot gnu.org
2015-01-19 18:15 ` redi at gcc dot gnu.org [this message]
2015-01-20 15:28 ` jakub at gcc dot gnu.org
2015-01-20 15:58 ` [Bug sanitizer/64632] " jakub at gcc dot gnu.org
2015-01-20 20:40 ` jakub at gcc dot gnu.org
2015-01-20 21:09 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64632-4-iJ655frIpU@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).