indexing arrays

Rob robpilling@gmail.com
Tue Nov 19 11:18:00 GMT 2013


On Mon, Nov 18, 2013 at 04:47:01PM +0100, Mischa Baars wrote:
>
> At least you have the example in case you need it, in my opinion the
> compiler is in error.

This isn't even gcc, you're just making noise. Try it with clang or read
the x86_64 ABI.

Surely it's common knowledge that if you're writing assembly, certain
registers are preserved across function calls? What about %ebp?

Compile this file, even on the lowest optimisation level (-O1) using
both gcc and clang, and you'll see that they're explicitly using %ebx to
save the value of `i'. It's not an accident.

int main(void)
{
	int i = save_me();
	f(g(), h());
	return i;
}

Regards,
Rob



More information about the Gcc-help mailing list