From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-08-25 18:43:23
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-
> > 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);
> > | ^~~~~~
That's because the assertion fails. a=9, b=1.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk