[Patch / RFC ] Fix libstdc++/36742 on the 4_2-branch

Paolo Carlini paolo.carlini@oracle.com
Mon Jul 7 10:55:00 GMT 2008


Hi,

apparently, aliasing days...

Anyway, I have a tentative patch for this bug, which affects only 4_2-branch (but, I understand, even after Ian's patches may well be latent on 4_3-branch and mainline).

Our old basic_string uses this _S_empty_rep_storage trick, which is a statically allocated array of size_type, not of plain chars. That, on one side ameliorates the alignment issues, on the other side certainly makes the whole thing weaker wrt aliasing (if I understand correctly). Thus my idea would be changing its type to array of chars while keeping the size_t alignment. Somehow, the patch works, 4_2 is fixed, and passes regtesting (ABI-included of course, mainline too), seems a definite improvement to me (by the way, in mainline, where the alignment attribute is finally fixed vs template, we can generically use __alignof__((size_type)), not size_t).

I'm mostly worried at the moment by ABI stability: _S_empty_rep_storage is *exported* and wheres it's just an array of chars, same size and same alignment of the old one, I fear code linking to the exported symbol can see the difference, somehow. Any help about that?

Thanks,
Paolo.

//////////////////
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_36742_draft
Type: application/octet-stream
Size: 1435 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20080707/e7ce712e/attachment.obj>


More information about the Libstdc++ mailing list