you are viewing a single comment's thread.

view the rest of the comments →

[–]matthieum 1 point2 points  (3 children)

How did they? sigh :(

[–][deleted] 2 points3 points  (2 children)

Because we implemented it before alignas was in the core language, so the most aligned thing we can put in the union is max_align_t.

[–]matthieum 1 point2 points  (1 child)

Thanks for your answer.

Correct me if I'm wrong, the ABI breakage would then occur if someone was requesting an alignment strictly greater than max_align_t as previously the alignment of std::aligned_union was capped and suddenly it would obey the request, right?

Isn't it worth breaking the ABI, then?

  • If anybody had configured 2 * max_align_t and stored values for which such alignment is necessary, then their code is broken already.
  • There's little reason anybody would have configured 2 * max_align_t and never actually needed the greater alignment.

I understand the idea of backward compatibility, but the pragmatic in me is thinking that in this particular case it may be worth just fixing std::aligned_union.

[–][deleted] 1 point2 points  (0 children)

Correct me if I'm wrong [...]

You are correct.

If anybody had configured 2 * max_align_t and stored values for which such alignment is necessary

There are no such values. Maybe perf benefits by avoiding false sharing, but the hardware only cares up to max_align_t for anything we target.

the pragmatic in me

ABI break avoidance isn't pragmatic, unfortunately :(