]> Cypherpunks repositories - gostls13.git/commitdiff
cc, ld: fix more gcc 4.3 -O2 compile bugs
authorRuss Cox <rsc@golang.org>
Thu, 12 Nov 2009 08:22:45 +0000 (00:22 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 12 Nov 2009 08:22:45 +0000 (00:22 -0800)
same as https://golang.org/cl/152088
in more files.

Fixes #83.

R=r, r1
https://golang.org/cl/152091

src/cmd/cc/lex.c
src/cmd/ld/go.c
src/cmd/ld/lib.c

index ff80bfb324ad7a7968a470102f2b4ac0d11e6c7f..9fbf3a3acdd0a09fa7be9ae869b00cde25f01a56 100644 (file)
@@ -411,8 +411,7 @@ lookup(void)
                h += *p++;
        }
        n = (p - symb) + 1;
-       if((int32)h < 0)
-               h = ~h;
+       h &= 0xffffff;
        h %= NHASH;
        c = symb[0];
        for(s = hash[h]; s != S; s = s->link) {
index aa006a847ef340d606759b21780f72564f9d00f9..8f0e66d3306bff189ba2b8b514277879da4f7947 100644 (file)
@@ -42,8 +42,8 @@ hashstr(char *name)
        h = 0;
        for(cp = name; *cp; h += *cp++)
                h *= 1119;
-       if(h < 0)
-               h = ~h;
+       // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it.
+       h &= 0xffffff;
        return h;
 }
 
index 99a76558d37f9d714821d18a08b6d3dde8ac014f..4a518c79b1ed5b046e6e93ec5b04d499aff14555 100644 (file)
@@ -384,8 +384,8 @@ lookup(char *symb, int v)
        for(p=symb; c = *p; p++)
                h = h+h+h + c;
        l = (p - symb) + 1;
-       if(h < 0)
-               h = ~h;
+       // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it.
+       h &= 0xffffff;
        h %= NHASH;
        for(s = hash[h]; s != S; s = s->link)
                if(s->version == v)