Bug 278821
Summary: | Add a compile-time equivalent to RELEASE_ASSERT_NOT_REACHED | ||
---|---|---|---|
Product: | WebKit | Reporter: | Gerald Squelart <g_squelart> |
Component: | Web Template Framework | Assignee: | Gerald Squelart <g_squelart> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | 278700 | ||
Bug Blocks: |
Gerald Squelart
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/134888391>
Gerald Squelart
Pull request: https://github.com/WebKit/WebKit/pull/32859
EWS
Committed 283957@main (221f446c9954): <https://commits.webkit.org/283957@main>
Reviewed commits have been landed. Closing PR #32859 and removing active labels.