This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug report
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: bug report
- From: Tom McLintock <mclintockbt at nswc dot navy dot mil>
- Date: Tue, 26 Oct 1999 15:45:16 -0400
I don't have the list of known bugs, so forgive me if this is a known
one.
The version of gcc I'm using is
Reading specs from
/usr/local/lib/gcc-lib/mips-sgi-irix6.5/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
on an sgi, and
Reading specs from
/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
on an hp
Here's some code:
mc.h
-----
typedef struct {
short red;
short green;
short blue;
} MapColor;
void ApplyColorByRGB(
#ifdef UseProtos
int channel,
int object,
MapColor mapcol,
int setflag
#endif
);
mc.c
-----
#include "mc.h"
#include <stdio.h>
void ApplyColorByRGB(
#ifdef UseProtos
int channel,
int object,
MapColor mapcol,
int setflag
#else
channel, object, mapcol, setflag
#endif
)
#ifndef UseProtos
int channel;
int object;
MapColor mapcol;
int setflag;
#endif
{
printf("channel=%d\nobject=%d\nmapcol={%d, %d, %d}\nsetflag=%d\n",
channel, object, mapcol.red, mapcol.green, mapcol.blue,
setflag);
}
main.c
-------
#include "mc.h"
#include <stdio.h>
main()
{
int channel = 1;
int object = 2;
int setflag = 4;
MapColor mapcol;
mapcol.red = 10000;
mapcol.green = 20000;
mapcol.blue = 30000;
printf("channel=%d\nobject=%d\nmapcol={%d, %d, %d}\nsetflag=%d\n\n",
channel, object, mapcol.red, mapcol.green, mapcol.blue,
setflag);
ApplyColorByRGB(channel, object, mapcol, setflag);
printf("\n\n");
}
the "makefile"
------------
cc -c mc.c
gcc main.c mc.o -o gcc_cc
echo gcc_cc:
gcc_cc
cc main.c mc.o -o cc_cc
echo cc_cc:
cc_cc
output on an sgi
-------------
gcc_cc:
channel=1
object=2
mapcol={10000, 20000, 30000}
setflag=4
channel=1
object=2
mapcol={0, 10000, 20000}
setflag=4
cc_cc:
channel=1
object=2
mapcol={10000, 20000, 30000}
setflag=4
channel=1
object=2
mapcol={10000, 20000, 30000}
setflag=4
output on an hp
-------------
gcc_cc:
channel=1
object=2
mapcol={10000, 20000, 30000}
setflag=4
channel=1
object=2
mapcol={20000, 30000, 2}
setflag=4
cc_cc:
channel=1
object=2
mapcol={10000, 20000, 30000}
setflag=4
channel=1
object=2
mapcol={10000, 20000, 30000}
setflag=4
Notice that when main.c is compiled with gcc, the MapColor struct mapcol
is not passed in to the ApplyColorByRGB function; when main.c is
compiled with the machine's native cc compiler, the struct is passed in
correctly. Also note that the struct is passed incorrectly in different
ways on each machine. It looks like a byte-alignment problem to me.
To fix this problem I would ordinarily compile mc.c (actually, the file
that mc.c represents in my application) using gcc, but I don't have the
source code for it.
Please let me know what's going on here. Thanks!