C++ Logo

liaison

Advanced search

[wg14/wg21 liaison] p2264, assert

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Mon, 8 Feb 2021 10:33:42 +0100
Hi,
just to give the discussion on

> P2264R0 (http://wg21.link/p2264r0) Make assert() macro user friendly
> for C and C++

a start. For me, the paper by itself is a no-brainer, `assert` should
have been `...` from the beginning, for all the reason that are given
in the paper.

Just some side remarks for the WG14ners, it looks to me that the C
text has some weaknesses and could be even more improved at the same
time.

(1) The current presentation has `scalar expression` in the syntax as
    if this were a syntax term (which it isn't), but then the text only
    talks about `expression`. I think this could be corrected to say
    just `expression` in the syntax.

(2) Currently, not passing a scalar expression is only UB and not a
    constraint violation. This looks weird to me. Generally we could
    have a new constraint section that says something like:

    "The type of the expression shall have an implicit conversion to
    `bool`."

    and change the corresponding sub-phrase of the description to

    "..., if the converted /expression/ is `false`, the `assert` macro ..."

Another possibility would be to give the pseudo-prototype for the
macro as

      void assert(bool expression);

which would imply all the above by the usual rules for calling
prototypes.


Thanks
Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2021-02-08 03:33:48