Elektrine lite

← Feed

@manx@mastodon.online

Post #2636431

2026-04-07 11:00 UTC

@andreasfertig@mas.to May I suggest that you explain more thoroughly that std::start_lifetime_as still requires properly aligned memory. In almost all cases, it is also Undefined Behaviour just like reinterpret_cast is, if the memory comes from somewhere that does not guarantee proper alignment for the destination type. In particular, I consider your older post and example at completely broken. Please do not teach it this way.

Replies (2)

  • @DanielaKEngert@hachyderm.io 2026-04-07 11:21

    @manx@mastodon.online @andreasfertig@mas.to The std::start_lifetime_as*() functions have constraints that e.g. reinterpret_cast<>() doesn't have: * type constraints: https://eel.is/c++draft/mem#obj.lifetime-1 * position constraints: https://eel.is/c++draft/mem#obj.lifetime-2 The latter is a precondition that could be strengthened and (partially) unconditionally checked for in a *hardened standard library implementation*. The former removes affected overloads when the constraints are not satisfied.

    Open ##2636432

  • @manx@mastodon.online 2026-04-16 11:00

    @andreasfertig@mas.to How is that still online without any correction at all?

    Open ##2636442