Bug in compiler ?
Hi,
I met buggy compiled C code.
There is declaration of called function:
typedef time_t TIME;
void
ack_lease (
struct packet *,
struct lease *,
unsigned int,
TIME,
char *,
int,
struct host_decl *
);
When this function was called by this way:
ack_lease (packet, lease, DHCPACK,
0,
msgbuf, ms_nulltp, (struct host_decl *)0);
then on begin of called function body parameters after fourth parameter was
all next parameters offset 4 bytes.
It is because compiler does not automatically converts 0 to 64-bit number,
but it pushes to stack 32-bit number even in declaration is 64-bit TIME. On
the other side called function calculates always with 64-bit number on the
stack, so there is reason for offset and locals after TIME parameter are
invalid in called function.
but
When this function was called by this way:
ack_lease (packet, lease, DHCPACK,
0ULL,
msgbuf, ms_nulltp, (struct host_decl *)0);
all is ok.
Compiler is from VS2005, version 14.00.50727.42 for 80x86.
The same code was ok in VS2003, so it seems that this behavior is only in
compiler for VS2005.
Peter Skvarka
SOFT IN ENGINES
date: Fri, 2 May 2008 10:54:02 -0700
author: Peter