3.0 branch--short arguments are incorrectly converted to type int
John David Anglin
dave@hiauly1.hia.nrc.ca
Tue Apr 3 13:23:00 GMT 2001
The following problem was noted under vax-dec-ultrix4.3 with the gcc
3.0 prerelease from 20010308. Intermittent failure of a chown system
call was observed. The chown call has two short arguments.
The problem can be seen with this little test program:
extern int f (short);
int g (short i) { return f (i); }
This produces the following assembly code when compiled with the new
prerelease:
#NO_APP
gcc2_compiled.:
___gnu_compiled_c:
.text
.align 1
.globl _g
_g:
.word 0x0
subl2 $2,sp
movw 4(ap),-(sp)
calls $1,_f
ret
Subtracting 2 bytes from the stack for the call leaves these two bytes
uninitialized. I believe that a cvtwl should be done instead to provide
the proper sign extension. I am guessing but it looks like PROMOTE_PROTOTYPES
needs to be defined for the vax.
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
More information about the Gcc-bugs
mailing list