[Bug c++/112296] __builtin_constant_p doesn't propagate through member functions

2023-10-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112296 --- Comment #3 from Jonathan Wakely --- (In reply to Barry Revzin from comment #0) > inline int direct(Span span) { > return __builtin_constant_p(span.size()); > } > > inline int indirect(Span span) { > size_t s = span.size(); > ret

[Bug c++/112296] __builtin_constant_p doesn't propagate through member functions

2023-10-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112296 --- Comment #2 from Jonathan Wakely --- I think you mean std::is_constant_evaluated, but that doesn't check values, it checks if the function is being evaluated as constexpr. And if-constexpr can't be used here either, that works like templates,

[Bug c++/112296] __builtin_constant_p doesn't propagate through member functions

2023-10-30 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112296 --- Comment #1 from Richard Biener --- __builtin_constant_p is limited by inlining, maybe you want to use if constexpr for this or the standard library facility I can't remember right now.