[PATCH] D35190: __builtin_constant_p should consider the parameter of a constexpr function as constant

Olivier Goffart via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 12 07:20:43 PDT 2017


ogoffart added a comment.

>   What if the constexpr function is called with in a non-constexpr context, e.g. with a random global variable as argument?

__builtin_constant_p will still return false in this case, contrary to gcc (whose behavior actually depends on the optimization level).

I think if we really want to get the exact gcc behavior, we need to mix it with the optimizer and generate some LLVM intrinsics. But what I was interested on with this patch is at least get  a closer behavior as GCC in a constexpr context


https://reviews.llvm.org/D35190





More information about the cfe-commits mailing list