David P. Riedel wrote:
On 8/21/21 11:54 AM, Peter Dimov via Boost wrote:
Ivan Matek wrote:
As you may know assert does not play nicely with constexpr evaluation.
It does. https://www.godbolt.org/z/KhPja6cEs
What am I missing here?
I click the above link and see the code
If I compile with gcc x86-64 trunk, I get the following:
source>: In function 'int main()': <source>:12:21: error: non-constant condition for static assertion 12 | static_assert(5 == func(9,1)); | ~~^~~~~~~~~~~~ In file included from /opt/compiler-explorer/gcc-trunk- 20210825/include/c++/12.0.0/cassert:44, from <source>:2: <source>:12:28: in 'constexpr' expansion of 'func(9, 1)' <source>:6:5: error: call to non-'constexpr' function 'void __assert_fail(const char*, const char*, unsigned int, const char*)' 6 | assert(a
That's because the assertion fails. a=9, b=1.