https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121479

--- Comment #2 from Anonymous <njuwy at smail dot nju.edu.cn> ---
(In reply to Jakub Jelinek from comment #1)
> That is not a bug, that is exactly how __builtin_constant_p is designed and
> documented:
> "The function returns the integer 1 if the argument is known
> to be a compile-time constant and 0 if it is not known to be a
> compile-time constant.  A return of 0 does not indicate that the
> value is _not_ a constant, but merely that GCC cannot prove it is a
> constant with the specified value of the '-O' option."

Thanks (In reply to Jakub Jelinek from comment #1)
> That is not a bug, that is exactly how __builtin_constant_p is designed and
> documented:
> "The function returns the integer 1 if the argument is known
> to be a compile-time constant and 0 if it is not known to be a
> compile-time constant.  A return of 0 does not indicate that the
> value is _not_ a constant, but merely that GCC cannot prove it is a
> constant with the specified value of the '-O' option."

Thanks for your reply. I will pay more attention to the use of builtin
functions.


BTW,I find that, at -O0, __builtin_constant_p in GCC will not return 1 even if
a constant variable (like "const int x=3;") is passed in, but llvm can.

https://godbolt.org/z/E946r7Pr4

Reply via email to