RESOLVED FIXED 278821
Add a compile-time equivalent to RELEASE_ASSERT_NOT_REACHED
https://bugs.webkit.org/show_bug.cgi?id=278821
Summary Add a compile-time equivalent to RELEASE_ASSERT_NOT_REACHED
Gerald Squelart
Reported 2024-08-28 15:11:31 PDT
In code using `if constexpr`, it can sometimes be useful to mark a branch as "unreachable" (for example when the above `if`s are supposed to cover all enumerations of an `enum`). This is traditionally done with `RELEASE_ASSERT_NOT_REACHED`, but in the `constexpr` case it would be useful to bring this assertion into the compilation phase, to catch it as early as possible. Tech note: The easiest way to achieve this would be `static_assert(false)`, however some compilers may still trigger this template-parameter-INdependent assertion even if the `constexpr` branch should not be compiled in any actual instantiation. There's a C++ proposal to fix this: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html But in the meantime, we need a static assertion that depends on a templated type, so that its evaluation is delayed until instantiations are actually created. The above paper gives a "valid workaround" that we can implement.
Attachments
Radar WebKit Bug Importer
Comment 1 2024-08-28 15:11:50 PDT
Gerald Squelart
Comment 2 2024-08-28 17:15:44 PDT
EWS
Comment 3 2024-09-19 15:47:29 PDT
Committed 283957@main (221f446c9954): <https://commits.webkit.org/283957@main> Reviewed commits have been landed. Closing PR #32859 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.