This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] DO_GLOBAL_CTORS_BODY needs uintptr_t
On Tue, Mar 17, 2009 at 4:48 PM, Ian Lance Taylor <iant@google.com> wrote:
> "O.Sezer" <sezeroz@gmail.com> writes:
>
>> * gbl-ctors.h (DO_GLOBAL_CTORS_BODY): cast to uintptr_t instead of
>> unsigned long to avoid the win64 warning.
>>
>> --- gcc/gcc/gbl-ctors.h~
>> +++ gcc/gcc/gbl-ctors.h
>> @@ -75,9 +75,9 @@ extern void __do_global_dtors (void);
>> #ifndef DO_GLOBAL_CTORS_BODY
>> #define DO_GLOBAL_CTORS_BODY \
>> do { \
>> - unsigned long nptrs = (unsigned long) __CTOR_LIST__[0]; \
>> + uintptr_t nptrs = (uintptr_t) __CTOR_LIST__[0]; \
>> unsigned i; \
>> - if (nptrs == (unsigned long)-1) \
>> + if (nptrs == (uintptr_t)-1) \
>> for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \
>> for (i = nptrs; i >= 1; i--) \
>> __CTOR_LIST__[i] (); \
>
>
> I like the idea but I'm not sure that uintptr_t is reliably defined at
> this point on all targets. Can you convince me that it is?
>
Nope, that I can't.
> Since this code is only compiled with the newly built gcc, other options
> would be to use __PTRDIFF_TYPE__ or __UINTMAX_TYPE__.
>
> Ian
>
AFAIK, __PTRDIFF_TYPE__ is defined (and not typedef'ed) as signed,
not unsigned. If it won't be a problem, __PTRDIFF_TYPE__ seems as
a better candidate to me, and can even be used in combination with
'unsigned' (although that might be ugly..)
Ozkan