#pragma pack() problems with gcc-2.95 19990608 on sparc-redhat-linux

GUYOMARCH Rémi rguyomarch@ifn.fr
Wed Jun 16 08:09:00 GMT 1999


btw, It's probably the same bug which was reported in 
http://egcs.cygnus.com/ml/egcs-bugs/1999-05/msg00488.html
and
http://egcs.cygnus.com/ml/egcs-bugs/1999-05/msg00046.html

> -----Original Message-----
> From:	GUYOMARCH Rémi 
> Sent:	Wednesday, June 16, 1999 5:00 PM
> To:	'egcs-bugs'
> Subject:	#pragma pack() problems with gcc-2.95 19990608 on
> sparc-redhat-linux
> 
> Here's a little test case which fail on gcc-2.95 19990608 but succeed on
> egcs 1.1.2 on the same platform (sparc-redhat-linux RH 5.2).
> 
> With gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release) :
> 
> 	$ gcc -g -Wall zz.cpp ; ./a.out 
> 	struct:      0x208c0
> 	logfiletype: 0x208c4
> 
> With gcc version gcc-2.95 19990608 (prerelease) :
> 
> 	$ egcc -g -Wall zz.cpp ; ./a.out 
> 	struct:      0x208c0
> 	logfiletype: 0x208c1		<-- int not aligned
> 	Bus error (core dumped)
> 
> 
> Yes, I know pragmas are evil, but this used to work with egcs 1.1.2.
> Btw, the info docs say that #pragma(0) should reset alignment to the
> defaults, but both compiler complains about a bad pragma.
> 
> Here's the source :
> --------------------------
> #include <stdio.h>
> 
> #pragma pack(1)
> struct {
>   char toto;
>   int titi;
>   char tata[3];
> } zz3;
> #pragma pack()
> 
> struct {
>   char percprint;  
>   int  logfileType;
> } logstatics;
> 
> void update( int *z ) { *z = 1; }
> 
> int main( void ) {
>   printf( "struct:      %p\n"
> 	  "logfiletype: %p\n",
> 	  &logstatics, &logstatics.logfileType );
>   update( &logstatics.logfileType );
> }
> --------------------------
> 
> -- 
> Rémi Guyomarch
> LAN / Network Admin
> Inventaire Forestier National
> French National Forest Inventory
> http://www.ifn.fr/
> 


More information about the Gcc-bugs mailing list