|
Boost : |
From: David P. Riedel (driedel_at_[hidden])
Date: 2021-08-25 18:39:21
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
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
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<b);
> | ^~~~~~
> /usr/include/assert.h:69:13: note: 'void __assert_fail(const char*, const char*, unsigned int, const char*)' declared here
> 69 | extern void __assert_fail (const char *__assertion, const char *__file,
> | ^~~~~~~~~~~~~
> Compiler returned: 1
Thanks
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk