Elektrine lite

← Feed

@manx@mastodon.online

Post #2636440

2026-04-07 12:57 UTC

@DanielaKEngert@hachyderm.io @andreasfertig@mas.to std::start_lifetime_as is probably fine for doing what it was designed to do, i.e. working around type confusion in legacy C APIs (I know of examples in the audio field), or C-style allocation functions. However, people apparently like to also teach it as some kind of crude de-serialization primitive. Even the original paper advertises this use case, which frankly horrifies me: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2590r2.pdf ...

Replies (1)

  • @manx@mastodon.online 2026-04-07 13:02

    @DanielaKEngert@hachyderm.io @andreasfertig@mas.to ... You really cannot just take any std::byte* from somewhere and just "de-serialize" it with std::start_lifetime_as to some type that might have alignment requirements greater than 1 byte. Whether doing things wrong results in language level UB, or in assertion failure due to stdlib hardening, or really any other run-time decision that results in process termination, does really not matter at all - the bug lies in the intent, not in its manifestation.

    Open ##2636441