On 22/07/15 09:07, Matthias Apitz wrote: > El día Wednesday, July 22, 2015 a las 08:59:52AM +0100, Andrew Haley escribió: > >> On 22/07/15 08:46, Matthias Apitz wrote: >>> Why does the gcc 3.4.3 correct this problem on the fly and stores >>> the full 64 bit pointer into the receiving char pointer, while the >>> gcc 4.4.2 does not? >>> >>> When this feature or behaviour was changed after gcc 3.4.3? >>> >>> Is this somehow a command line flag for gcc to control the behaviour? >> >> The question is whether the 64-bit function pointer is truncated when >> it is read from register RAX on return from the function. This is a >> matter for the system ABI: it's not something that GCC decides. The >> x86_64 ABI changed during this timeframe, and you might be seeing an >> effect of that. I can't remember exactly when the changes were made. > > This is not on x86, but SPARC. Sorry, yes, I read it too quickly and was thinking of Solaris x86. First coffee of the day. >> However, this is also the kind of thing which can also vary depending >> on the optimization level. Turn on optimization and it might all >> break. You can't depend on good luck to make this work. > > I agree here. The question was more to understand why it works on 3.4.3. Sure, I get that. Maybe somebody will do the work to look inside the compiler and see why the code generation is different. But with undefined behaviour on an obsolete compiler, you may be out of luck. Andrew.