String packing

Andi Kleen ak@suse.de
Sat Aug 25 23:28:00 GMT 2001


Frank Klemm <pfk@fuchs.offl.uni-jena.de> writes:

> How to avoid the silly string alignment:
> 
> char  string1 [] = "Hello";
> char  string2 [] = "world";
> 
> Hex dump of the binary:
> 
> 	H e l l o . . . . . . . . . . .
> 	. . . . . . . . . . . . . . . . 
> 	w o r l d . . . . . . . . . . .
> 	. . . . . . . . . . . . . . . . 


I just tried your example with gcc 2.95.3, gcc 3.0.0 and a recent gcc 3.1 
development snapshot with binutils 2.9.5.0.24 on linux and all generate
perfect packing for your example. If it isn't the case on your box 
I would more suspect the binutils than the compiler.

> On the Pentium 4 the fastest code I often get with '-Os', I have some examples
> where '-O3' generates code with 40% of the performance than the '-Os' code.

If you have test cases that show such a  problem on gcc 3.1 I'm sure they would
be welcome.


-Andi



More information about the Gcc mailing list