This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

3.0 branch--short arguments are incorrectly converted to type int


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]