[clang] Fix __builtin_object_size calculation for references of unknown origin in C++23 (PR #157778)
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 18 12:38:55 PDT 2025
ahatanak wrote:
> In any context where the standard requires constant evaluation, we have to return false, probably. (This corresponds, roughly, to Info.InConstantContext. I don't think we have a bit that precisely corresponds, though.)
For Type=3, conditionally returning false when `InConstantContext` is set triggered undesirable warnings (e.g., clang emitted a division-by-zero warning for function `f3` in `constant-expression-p2280r4.cpp`), so I removed that check. As a result, CodeGen now emits a lower bound of 0 in cases where it could otherwise emit a tighter bound using the conservative lower bound (see `clang/test/CodeGenCXX/builtin-object-size.cpp`).
https://github.com/llvm/llvm-project/pull/157778
More information about the cfe-commits
mailing list