News for hackers. Stuff that matters.
Re:Wordlexpr: Compile-Time Wordle in C++20 by fathyb on Monday February 28, 2022 @04:40AM (#30498087)
Wondering what happens if you allocate a chunk of uninitialized memory inside a constexpr? Could this be used for a quick constexpr RNG seed?
Re:Wordlexpr: Compile-Time Wordle in C++20 by jcelerier on Monday February 28, 2022 @05:59AM (#30498548)
A very neat thing of constexpr is that it does not have undefined behaviour ; any thing that would cause UB at run-time is flagged as a compile error. Every variable must be fully initialized.
Re:Wordlexpr: Compile-Time Wordle in C++20 by xroche on Monday February 28, 2022 @04:54AM (#30498178)
You simply can't. The constexpr environment won't let you have uninitialized variables/memory anywhere. It won't let you access dangling/out-of-bounds pointers either, overflow two-complement types, etc.
Re:Wordlexpr: Compile-Time Wordle in C++20 by flqn on Monday February 28, 2022 @05:59AM (#30498546)
Accessing uninitialized objects is undefined behaviour, which traps in the constexpr context.