This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why the difference of two global pointers is not a constant?


"Rafael Espíndola" <rafael.espindola@gmail.com> writes:

>> because that is what the language standard says.
>>
>> In general, the difference between two global pointers is something
>> known only to the linker -- too late to evaluate as constant
>> expression.
> In the particular case of two static functions or two static global
> pointers, it is possible for the compiler to compute it. Isn't it? I
> think that the linker will reorder the sections, but not the functions
> inside a section.

This will fail with -ffunction-sections/-fdata-sections.  Also, the
address of a function may be quite different from the address of where the
code is stored, due to function descriptors.  A function isn't an object,
after all.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]