This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/47979] Problem in comparing integers
- From: "xiaofengguo at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 3 Mar 2011 20:36:37 +0000
- Subject: [Bug rtl-optimization/47979] Problem in comparing integers
- Auto-submitted: auto-generated
- References: <bug-47979-4@http.gcc.gnu.org/bugzilla/>
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;
}
===================================================