[PATCH] Improved __builtin_constant_p
Richard Smith
richard at metafoo.co.uk
Mon Jul 14 19:50:57 PDT 2014
This makes Clang's constant expression evaluator and its IR generation disagree about the value of `__builtin_constant_p`. That seems dangerous to me, so I'd like to understand the justification for this a bit better. Random example of why this is dangerous:
int f(int n) {
if (!__builtin_constant_p(n))
return 0;
}
int k = f(0);
Here, we'll suppress the `-Wreturn-type` warning because the frontend believes that it's impossible to reach the `}` of `f`. But when we generate IR, we'll fall off the function and experience nasal demons.
What's the motivation behind this change?
http://reviews.llvm.org/D4492
More information about the cfe-commits
mailing list