]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix undefined behaviour warning in subr.c
authorDave Cheney <dave@cheney.net>
Mon, 8 Sep 2014 05:36:21 +0000 (15:36 +1000)
committerDave Cheney <dave@cheney.net>
Mon, 8 Sep 2014 05:36:21 +0000 (15:36 +1000)
Fixes warning

/home/dfc/go/src/cmd/gc/subr.c:3469:8: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64' (aka 'long'); cast to an unsigned type to negate this value to itself

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/141220043

src/cmd/gc/subr.c

index 93600c688be9a17b3cc9f0aa93f95a4c4b8005de..666be9667923a1b03103796f721cd7047bff83dd 100644 (file)
@@ -3466,7 +3466,7 @@ smagic(Magic *m)
        p = m->w-1;
        ad = m->sd;
        if(m->sd < 0)
-               ad = -m->sd;
+               ad = -(uvlong)m->sd;
 
        // bad denominators
        if(ad == 0 || ad == 1 || ad == two31) {