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++/11295] [3.3/3.4 Regression] *reinterpret_cast<std::string *> causes ICE


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From jfc at legra dot com  2003-06-23 22:12 -------
No question that the behavior isn't defined, but I dispute that it can't work.

My example is derived from similar code which does seem to do what I intended.

static char c[] = {3,0,0,0, 4,0,0,0, 0,0,0,0, 'H', 'i', '!', '\0'};

std::string fakestatic()
{
  struct fakestring { void *p; } rv;
  rv.p = &c[12];
  return *reinterpret_cast<std::string *>(&rv);
}

With the particular string implementation I am using, this appears to generate a
usable std::string object.  And it doesn't crash the compiler.


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