[libcxx-commits] [libcxx] [libc++][hardening] Always enable all checks during constant evaluation (PR #107713)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 13 07:06:25 PDT 2024
https://github.com/ldionne commented:
I would like us to settle on https://github.com/llvm/llvm-project/pull/91801 first.
My mental model is that hardening is a configuration setting of its own, and I'm not sure that coupling it with something else is a good idea. If hardening is enabled and you run into library-UB inside a constant expression, then you'd get the hardening check. But I'm not certain that forcing the hardening checks on people just because they are in a constant expression makes sense.
This is both philosophical and practical. I wouldn't expect that running code in a constant expression behaves any differently than running it at runtime (except where strictly necessary because we can't actually implement X or Y inside constexpr). Making these two things non-orthogonal (when they are naturally orthogonal) reduces the generality of the library.
On the flipside, it is true that the compiler behaves differently w.r.t. UB inside constant expressions (ignored at runtime, diagnosed at compile-time), so one could argue that this makes the library and the compiler behavior more consistent.
Either way, I feel like piggy-backing on `_LIBCPP_ASSUME` isn't what we really want to do here if we move forward with the patch, given that #91801 makes a lot of sense but it would conflict with this patch.
https://github.com/llvm/llvm-project/pull/107713
More information about the libcxx-commits
mailing list