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/17169] New: optimization bug


/* gcc-3.4.1 optimization bug

  gcc -o foo foo.c -O0 ok
  gcc -o foo foo.c -O1 bug

% ./config.guess
ia64-unknown-linux-gnu
%
% gcc -v
Reading specs from /u/kminola/public/gcc-3.4.1/ia64-Linux/bin/../lib/gcc/ia64-un
known-linux-gnu/3.4.1/specs
Configured with: /u/kminola/public/gcc-3.4.1/src/gcc-3.4.1/configure --enable-la
nguages=c --prefix=/u/kminola/public/gcc-3.4.1/ia64-Linux
Thread model: posix
gcc version 3.4.1
%

does NOT exist in gcc-3.5-20040711 */

#include <stdio.h>

#define GMP_RNDU 2
#define GMP_RNDD 3

int
bar (long a, int rnd_mode)
{
  int signx;
  long b;

  b = a >> 31;
  if (b) {
    signx = -1;
  } else { 
    signx = 1;
  } 

  if (signx < 0 && rnd_mode == GMP_RNDD)
  {
    return -1;
  }
  if (signx > 0 && rnd_mode == GMP_RNDU)
  {
    return 1;
  }
  return 2;
}

int
main (int argc, char *argv[])
{
  int val;
  long a;

  a = 1;
  val = bar (a, GMP_RNDU);
  if (val == 2) {
    printf("bug!\n");
  } else {
    printf("ok!\n");
  }

  return 0;
}

-- 
           Summary: optimization bug
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kminola at eng dot umd dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: ia64-unknown-linux-gnu
  GCC host triplet: ia64-unknown-linux-gnu
GCC target triplet: ia64-unknown-linux-gnu


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


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