------- Additional Comments From wilson at gcc dot gnu dot org 2005-01-05 03:44 ------- This question was asked and mostly answered on the gcc mailing list. http://gcc.gnu.org/ml/gcc/2004-12/msg00231.html http://gcc.gnu.org/ml/gcc/2004-12/msg00234.html
As per the ABI, small local data ("own" data) is placed in the small data section in the GOT, where it can be accessed with a single memory reference. If we put it in the read-only data section, it would require two memory references to access it, resulting in slower code. Since the C testcase is invalid, this is not a good enough reason to disable an optimization by default. However, as Richard Henderson mentioned, we could optionally put the variable in a read-only data section if the user requested it via an option, or if the Fortran standard requires it. I don't know if the Fortran standard requires this, I doubt that it does. Incidentally, this issue is not unique to the IA-64 port. There are other targets that behave the same way, mips-elf for instance. So you may still have this problem when porting code to other systems even if the IA-64 port was fixed. There is an option that will make your testcase work as you expect, the -mno-sdata option. This is overkill for your purposes though, as this prevents any variable from going in sdata, whereas you only want to prevent putting const variables in sdata. -- What |Removed |Added ---------------------------------------------------------------------------- CC| |wilson at gcc dot gnu dot | |org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18566