This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Documentation bug for __builtin_choose_expr
- From: Andreas Schwab <schwab at suse dot de>
- To: Jamie Lokier <jamie at shareable dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 22 Nov 2004 11:42:15 +0100
- Subject: Re: Documentation bug for __builtin_choose_expr
- References: <20041122042652.GA26998@mail.shareable.org>
Jamie Lokier <jamie@shareable.org> writes:
> The documentation for __builtin_choose_expr says:
>
> -- Built-in Function: TYPE __builtin_choose_expr (CONST_EXP, EXP1, EXP2)
> You can use the built-in function `__builtin_choose_expr' to
> evaluate code depending on the value of a constant expression.
> This built-in function returns EXP1 if CONST_EXP, which is a
> constant expression that must be able to be determined at compile
> time, is nonzero. Otherwise it returns 0.
>
> This built-in function is analogous to the `? :' operator in C,
> except that the expression returned has its type unaltered by
> promotion rules. Also, the built-in function does not evaluate
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> the expression that was not chosen. For example, if CONST_EXP
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> evaluates to true, EXP2 is not evaluated even if it has
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> side-effects.
> ^^^^^^^^^^^^^
>
> The way this is written implies that the underscored behaviour is
> different from the `? :' operator in C.
I don't see that. For me the word "also" implies "another analogousness".
IMHO this is fact is worth noting because the usual rules for function
calls in C is to evaluate all its arguments first, whereas this builtin
does not do that even though it uses a function-like notation.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."