This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [RFA record/replay] cast to avoid compiler warning


Mark Kettenis <mark.kettenis@xs4all.nl> writes:

>> From: Andreas Schwab <schwab@suse.de>
>> Date: Sun, 05 Oct 2008 09:11:27 +0200
>> 
>> Mark Kettenis <mark.kettenis@xs4all.nl> writes:
>> 
>> >> Date: Sat, 04 Oct 2008 11:42:47 -0700
>> >> From: Michael Snyder <msnyder@vmware.com>
>> >> 
>> >> Sizeof returns size_t, which is not always the same as int.
>> >> This cast will prevent compiler warnings on some architectures
>> >> (eg. x86_64)
>> >
>> > This is wrong!  Better cast to unsigned long and print as %lu.
>> 
>> The value will always be a small number.
>
> It is still a bad example.  People may copy the idiom and uses it on
> cases where the value is not a small number.

If sizeof returns a too big number you should probably rethink your data
types.

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]