This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/19449] New: __builtin_constant_p cannot resolve to const when optimizing


Given the following code:

#define SHIFTLEFT(a,b) __builtin_choose_expr(__builtin_constant_p(b), \
      ((a) << (b)), \
      ((a) << (MIN(31,MAX(-31,(b))))))

int foo(int a, int b) { return SHIFTLEFT (a, b); }

the compiler will error:
gcc -O4 gcctest.c 
gcctest.c: In function `foo':
gcctest.c:5: error: first argument to __builtin_choose_expr not a constant

According to the documentation to __builtin_constant_p, it should resolve
to 0 if the compiler cannot prove that the argument is a constant.

-- 
           Summary: __builtin_constant_p cannot resolve to const when
                    optimizing
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: eplondke at gmail dot com
                CC: eplondke at gmail dot com,gcc-bugs at gcc dot gnu dot
                    org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: arm-unknown-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]