[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 12 00:50:45 PST 2025
philnik777 wrote:
> > Yes, that's the interesting question. Currently we assume that if __builtin_constant_p(__begin <= __ptr && __ptr < __end) is false, __ptr can't be within the the range [__begin, __ptr).
>
> Thinking about this some more, I'm not sure if this is even true. `__builtin_constant_p` will return `true` if that comparison can be folded, it doesn't matter if the result of the comparison is true or not: https://godbolt.org/z/fchbK977T
I think you're missing an important thing: If `__builtin_constant_p` is true we do _not_ assume that the pointer is in fact in range. If `__builtin_constant_p` is true, we _only_ assume that we are allowed to compare the pointers.
https://github.com/llvm/llvm-project/pull/122099
More information about the cfe-commits
mailing list