[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost
Subject:    Re: [boost] Does boost have an assert that works nicely with constexpr evaluation, and if not should
From:       "David P. Riedel via Boost" <boost () lists ! boost ! org>
Date:       2021-08-25 18:59:05
Message-ID: e52c3375-78f1-191d-712e-eb2ebea9e242 () cox ! net
[Download RAW message or body]


On 8/25/21 2:43 PM, Peter Dimov wrote:
> 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<b);
>>>        |     ^~~~~~
> That's because the assertion fails. a=9, b=1.
>

> Doh (smacks head)


Thank you !   😁




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic