This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

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


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.

//////////////////

Attachment: patch_36742_draft
Description: Binary data


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