]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/doc: adjust __builtin_choose_expr() description
authorJan Beulich <jbeulich@suse.com>
Wed, 9 Oct 2024 07:36:42 +0000 (09:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 9 Oct 2024 07:36:42 +0000 (09:36 +0200)
Present wording has misled people to believe the ?: operator would be
evaluating all three of the involved expressions.

gcc/

* doc/extend.texi: Clarify __builtin_choose_expr()
(dis)similarity to the ?: operator.

gcc/doc/extend.texi

index f46c3df330300c614ceb4b176790af246edacfd0..302c3299ede862d9e57c8d62c692609412a7ab8c 100644 (file)
@@ -15153,11 +15153,12 @@ evaluate code depending on the value of a constant expression.  This
 built-in function returns @var{exp1} if @var{const_exp}, which is an
 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
 
-This built-in function is analogous to the @samp{? :} 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 is not chosen.  For example, if @var{const_exp} evaluates to @code{true},
-@var{exp2} is not evaluated even if it has side effects.
+Like the @samp{? :} operator, this built-in function does not evaluate the
+expression that is not chosen.  For example, if @var{const_exp} evaluates to
+@code{true}, @var{exp2} is not evaluated even if it has side effects.  On the
+other hand, @code{__builtin_choose_expr} differs from @samp{? :} in that the
+first operand must be a compile-time constant, and the other operands are not
+subject to the @samp{? :} type constraints and promotions.
 
 This built-in function can return an lvalue if the chosen argument is an
 lvalue.