ref: 222655d71caa72a961f0a1573b42f48a891c5808
parent: f1182f58c64e86472355891de7a035d984032d06
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Aug 10 19:03:19 EDT 2014
Use type size in increments of pointers in cc1 The code was using always a value of 1, even in the case of pointers, where the correct value is the size of the pointer.
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -340,6 +340,7 @@
incdec(Node *np, char op)
{
Type *tp = np->type;
+ Node *inc;
chklvalue(np, np->type);
@@ -347,11 +348,15 @@
case PTR:
if (!tp->defined)
error("invalid use of indefined type");
+ inc = sizeofcode(tp->type);
+ break;
case INT: case FLOAT:
- return arithmetic(op, np, symcode(one));
+ inc = symcode(one);
+ break;
default:
error("incorrect type in arithmetic operation");
}
+ return arithmetic(op, np, inc);
}
static Node *
--
⑨