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 rtl-optimization/47979] Problem in comparing integers


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

--- Comment #1 from Xiaofeng Guo <xiaofengguo at google dot com> 2011-03-03 20:36:32 UTC ---
Because I can't find the attachment in the thread, add the text below for
debugging easily.

==================================================
#include <stdio.h>
#include <string.h>

int main() {
  const char *str = "1234567";

  int hash = 17;
  for (int i = 0; i < strlen(str); ++i) {
    hash = 37 * hash + str[i];
  }
  printf("hash = %d, %d\n", hash, hash < 0);
  int result = (hash < 0) ? (-hash) : hash;
  printf("result = %d\n", result);
  return 0;
}
===================================================


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