This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/19495] basic_string::_M_rep() can produce an unnaturally aligned pointer to _Rep
- From: "ncm-nospam at cantrip dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jan 2005 15:37:24 -0000
- Subject: [Bug libstdc++/19495] basic_string::_M_rep() can produce an unnaturally aligned pointer to _Rep
- References: <20050118051448.19495.bje@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From ncm-nospam at cantrip dot org 2005-01-21 15:37 -------
Hmm, it's a little more complicated than I said, although it might be
academic. There's an implicit assumption in the code that any type
on which basic_string<> might be instantiated has no stricter alignment
than _Rep itself. But that's a different bug. Probably the right way
to fix it is to replace the first member of _Rep with an anonymous union:
size_type _M_length;
becomes
union { size_type _M_length; _Some_big_aligned_type _M_alignment_dummy; };
I don't know if gcc supplies a built-in typedef for that. Without
checking, I think tr1 must do. I believe this can also be done
without breaking ABI on any actual target.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19495