News for hackers. Stuff that matters.
Re:Hardening the C++ Standard Library at scale by maccard on Saturday November 29, 2025 @02:22PM (#46090029)
>null will always trigger access violation..

No, it won't. https://gcc.godbolt.org/z/Mz8sqKvad

Re:Hardening the C++ Standard Library at scale by TinkersW on Saturday November 29, 2025 @02:31PM (#46090089)
Oh my bad, I read that as nullptr, I use a custom optional that does not support such a silly mode as "disengaged"
Re:Hardening the C++ Standard Library at scale by canyp on Saturday November 29, 2025 @02:44PM (#46090187)
How is that an optional then?

The problem is not nullopt, but that the client code can simply dereference the optional instead of being forced to pattern-match. And the next problem, like the other guy mentioned above, is that you cannot make any claims about what will happen when you do so because the standard just says "UB". Other languages like Haskell also have things like fromJust, but at least the behaviour is well-defined when the value is Nothing.

Re:Hardening the C++ Standard Library at scale by maccard on Saturday November 29, 2025 @04:55PM (#46091156)
What do you return if there is no value set? That’s the entire point of optional.