Compiler option -fpack-struct does not work

Joe K Krause joek@LESTERELECTRICAL.com
Thu Feb 17 06:31:00 GMT 2000


Compiler version 2.95 (downloaded from DJGPP site) does not do anything with
the -fpack-struct option.

The attached code demonstrates the improper access of the parts of a
structure.

Example code is included, the command used to compile the program is:
	gcc x.c -fpack-struct

The resulting incorrect output of the resulting executable is:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13
x1 = 03020100
x2 = 04
x3 = 0B0A0908

If the third member in the structure had been accessed properly the
resulting output would be:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13
x1 = 03020100
x2 = 04
x3 = 08070605

The correct output of the program used the same command line to compile the
program except the compiler was version egcs-2.91.57 from Cygnus Solutions.


Joe Krause
Engineering Department
Lester Electrical
(402) 441-3720, EXT. 260

 <<x.c>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x.c
Type: text/x-c
Size: 456 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000217/f5eeba2d/attachment.bin>


More information about the Gcc-bugs mailing list