This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA record/replay] cast to avoid compiler warning
> 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. Why rely on the fact
that it always will be a small number if you can fix it properly?