Hi Martin,

On Mon, 27 Feb 2017, Martin Sebor wrote:
> Sorry to be jumping in so late. I only noticed this bit now.
> 
> I would suggest to say that these new built-ins evaluate to integer
> constant expressions when their arguments do.  Not all C programmers
> are familiar with C++ constexpr so they may not understand the use
> use case.  The request for these built-ins also came from a C user
> and was specifically motivated by avoiding -Woverflow warnings so
> adding an example demonstrating that might be helpful as well.
> Something like this:
> 
>   ... Calls to these built-ins with integer constant arguments
>   evaluate to integer constants expressions.</p>
>   <p>For example, in the following, <code>c</code> is assigned
>   the result of <code>a * b</code> only if the multiplication
>   does not overflow, otherwise it is assigned the value zero.
>   The multiplication is performed at compile-time and without
>   triggering a <code>-Woverflow</code> warning.

</p>

>   <blockquote>
>     <pre>enum {
>   a = 12345678,
>   b = 87654321,
>   c = __builtin_mul_overflow_p (a, b, a) ? 0 : a * b
> };</pre>
>   </blockquote></li>

this works for me, modulo the closing </p> which I believe will be
necessary.  Were you seeing approval for this from someone?  (If so,
that may not have been me. ;-)

Gerald

Reply via email to