Possible Compiler Bug
Brunner, Brian T
Brian.T.Brunner@GAI-Tronics.com
Thu Aug 29 08:48:00 GMT 2002
I don't know if this is a known bug, or not a bug, etc. I'm
compiler-ignorant.
We used HIGH_C to compile C/C++ code to an AMPRO-brand CPU board
(486/pentium-based embedded machines).
My Mission, should I choose to remain employed, is to port this code to a
new CPU card (Pentium-based) with LINUX as the new OS.
New boards, when networked in systems with old boards, must look like old
boards to the other old boards. In
particular, SMNP-shared data (Shared Memory Network Protocol) from a
Linux/New cpu must be bitwise identical to
the data sent by old CPU/OS machines. This involves shipping complex packed
structures via ethernet and RS485 connections.
I bought Red Hat 7.2 and installed the default GCC compiler.
It appears that the compiler (ISTR version 2.96) does not always pack
correctly.
Sometimes the compiler is silent about the failure to pack, (I've found two
places so far where the packing was not done
but the compiler failed to alert me about it) and sometimes the compiler
warns me that the ((__attribute__)) __packed__
is ignored.
When the packing fails, there has ALWAYS been an array of structures within
another structure.
struct {
int data1i;
char data1c;
struct {
int data2i1;
char data2c;
int data2i2;
} mumble[2] ((__attribute__)) __packed__ ;
} foo[2] ((__attribute__)) __packed__;
The case where this gives me the most violent grief is in a templated class,
with two instantiations involving distinct class data, and only one of the
two has this nested struct packing problem.
Since this structure is passed via ethernet to old CPU/OS machines, the
alignments and packings must match.
Does this ring any bells? I could not find this in the known bug list.
I am severely leery about installing and building a new version of the
compiler (I'm just plain scared of unknowns of that size).
If you are confident that 'upgrading to the latest version of gcc' is as
simple as download, unzip, and make (and that the bug I report has been
identified and cured between 2.96 and latest); I'll give it a shot.
Brian Brunner (Embedded/Real-Time software engineer now masquerading as our
'Resident Linux Expert').
More information about the Gcc-bugs
mailing list