http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60722 Bug ID: 60722 Summary: __builtin_choose_expr() does not allow 'CONST_EXP' using const variable Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: yann at droneaud dot fr Created attachment 32498 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32498&action=edit testcase Hi, I'm trying to use __builtin_choose_expr() with a test against a const variable: #define VALUE 123 int test(void) { const int value = VALUE; int v1, v2; v1 = __builtin_choose_expr(__builtin_constant_p(VALUE), (__builtin_choose_expr(VALUE >= 10, 2, (__builtin_choose_expr(VALUE >= 0, 1, 0)))), -1); v1 = __builtin_choose_expr(__builtin_constant_p(value), (__builtin_choose_expr(value >= 10, 2, (__builtin_choose_expr(value >= 0, 1, 0)))), -1); return v1 - v2; } The first expression is considering a constant defined as a macro. And the second expression is considering a constant variable. With gcc 4.9.0 20140313 (experimental), I'm facing the following error: $ /opt/gcc/bin/gcc -O2 -c test.c test.c: In function ‘test’: test.c:21:11: erreur: first argument to ‘__builtin_choose_expr’ not a constant (__builtin_choose_expr(value >= 0, ^ test.c:19:9: erreur: first argument to ‘__builtin_choose_expr’ not a constant (__builtin_choose_expr(value >= 10, ^ (Note: with gcc 4.8, I'm also having the issue with _builtin_constant_p(value), as bug #19449) It's a pity gcc is not able to consider (value >= 0) as a constant expression while its obvious that 'value' is a constant variable (!). It makes usage of __builtin_choose_expr() not applicable in my case. >From gcc-bugs-return-447955-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Mar 31 14:33:04 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 8662 invoked by alias); 31 Mar 2014 14:33:04 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 8529 invoked by uid 48); 31 Mar 2014 14:33:01 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/60653] [4.9 Regression] gfortran: ICE (segmentation fault) in lra Date: Mon, 31 Mar 2014 14:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg02824.txt.bz2 Content-length: 371 http://gcc.gnu.org/bugzilla/show_bug.cgi?id`653 --- Comment #8 from Tobias Burnus --- Created attachment 32499 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2499&actioníit Reduced Fortran test case (use .f or .f90 suffix) Reduced test case attached. Compile on arm-linux-gnueabihf with "gfortran -O1"; works with "gfortran -O0".