From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13858 invoked by alias); 22 Nov 2004 04:26:58 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 13776 invoked from network); 22 Nov 2004 04:26:53 -0000 Received: from unknown (HELO mail.shareable.org) (81.29.64.88) by sourceware.org with SMTP; 22 Nov 2004 04:26:53 -0000 Received: from mail.shareable.org (localhost [127.0.0.1]) by mail.shareable.org (8.12.8/8.12.8) with ESMTP id iAM4Qr81027160 for ; Mon, 22 Nov 2004 04:26:53 GMT Received: (from jamie@localhost) by mail.shareable.org (8.12.8/8.12.8/Submit) id iAM4Qq1x027158 for gcc@gcc.gnu.org; Mon, 22 Nov 2004 04:26:53 GMT Date: Mon, 22 Nov 2004 08:06:00 -0000 From: Jamie Lokier To: gcc@gcc.gnu.org Subject: Documentation bug for __builtin_choose_expr Message-ID: <20041122042652.GA26998@mail.shareable.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2004-11/txt/msg00733.txt.bz2 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. But the `? :' operator does not evaluate the expression that was not chosen either. If the condition evaluates to true, EXP2 is not evaluated in `COND ? EXP1 : EXP2'. It would be better to replace that paragraph with: This built-in function is analogous to the `? :' operator in C, except that the expression returned has its type unaltered by promotion rules. If there is some other effect of __builtin_choose_expr, for example if it were to inhibit compilation or warnings in the unselected branch in some way, it would be useful to mention that. I don't know of any such effects. (Inhibiting warnings in the unselected branch and promising to not expand large inline functions in that branch would be a useful addition imho). -- Jamie