[clang] [ConstEval] Fix crash when comparing strings past the end (PR #137078)
Henrik G. Olsson via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 23 16:36:26 PDT 2025
hnrklssn wrote:
> Thanks for the fix!
>
> I was wondering if the new code paths should actually return `true` not `false`, but I think it makes sense that for a comparison like `"hello" + 6 == "world"`, we say that the strings are _not_ potentially-overlapping but we instead detect the case of comparing a past-the-end pointer to one complete object against the start of another complete object.
That's an interesting thought. I tried it out real quick to see what the difference would be. Instead of `comparison against pointer '&"foo"[4]' that points past the end of a complete object has unspecified value`, we get `comparison of addresses of potentially overlapping literals has unspecified value`. I haven't investigated the code paths to see whether it's guaranteed that we always get that diagnostic, but I do think it's more useful with the diagnostic being specific about past-the-end being the issue.
https://github.com/llvm/llvm-project/pull/137078
More information about the cfe-commits
mailing list