summary refs log tree commit diff
path: root/sysv.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-08 09:40:07 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-08 09:41:59 -0400
commit15cee065a57ed7c7f5272bb6b60f7518121ec4da (patch)
treed55eba36212344720499bd3f0d3b5ca84cc2d180 /sysv.c
parenta7fb69fd782470e20553e90e97fcc13f9218e2ae (diff)
downloadroux-15cee065a57ed7c7f5272bb6b60f7518121ec4da.tar.gz
simplify a buggy test
I found it by compiling -O2 and seeing the ABI code
fail.  Further investigation revealed GCC trimmed
away the last iteration of the loop because I was
accessing the third element of an array of size two.
This is undefined behavior, so GCC "proved" that the
last iteration was never run.
Diffstat (limited to 'sysv.c')
-rw-r--r--sysv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sysv.c b/sysv.c
index 5a8934b..34f2904 100644
--- a/sysv.c
+++ b/sysv.c
@@ -92,7 +92,7 @@ retr(Ref reg[2], AClass *aret)
 
 	nr[0] = nr[1] = 0;
 	ca = 0;
-	for (n=0; aret->cls[n]>=0 && n<2; n++) {
+	for (n=0; (uint)n*8<aret->size; n++) {
 		k = KBASE(aret->cls[n]);
 		reg[n] = TMP(retreg[k][nr[k]++]);
 		ca += 1 << (2 * k);