What is the gcc option which reorders the variables' address?

Leo Prete smoltest@gmail.com
Wed Apr 11 10:52:00 GMT 2007


Hi,
Compiling the code below as "gcc -O1 test.c" I obtain the output:
0xbffff958 0xbffff95c 0xbffff960
That is, bytes 59, 5a and 5b are unused.

Instead, compiling it as  "gcc -O2 test.c" I obtain:
0xbffff958 0xbffff95c 0xbffff959
That is, variables are reordered to get a more memory efficient.

My question is: Which GCC option allows variables reordering?

I would like to obtain just variable reordering, not all "-O2"
package; reading in the gcc manual, I singularly tried with all
options in "-O2" but no one reorders the variables.

many thanks,
Leo

***
THE CODE:

#include <stdio.h>

main(int argc, char **argv)
{	
	char a;
	long b;
	char c;

	printf("%p %p %p\n", &a, &b, &c);
}



More information about the Gcc-help mailing list