This is the mail archive of the
mailing list for the GCC project.
Re: [Patch] Conversion warnings when truncating 64-bit types (v1)
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Martin von Loewis <Martin dot vonLoewis at hpi dot uni-potsdam dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Oct 2006 21:09:12 -0700
- Subject: Re: [Patch] Conversion warnings when truncating 64-bit types (v1)
- References: <453E23BB.firstname.lastname@example.org>
On Tue, 2006-10-24 at 16:31 +0200, Martin von Loewis wrote:
> When porting applications to 64-bit platforms, code is often found
> to use the wrong types, in particular, to use int or long to represent
> the sizes and offsets (e.g. results from sizeof/strlen). If the actual
> size exceeds the range of the target type, gcc will silently truncate
> the result.
I don't believe this should be called w64 since we also support 16bit
targets so the attribute does not work for those targets when porting
from a 32bit target to a 16bit target. It also seems like a warning
which could go wrong easily and people abuse it by just adding the
attribute to their code to get around the warning.
Also what about porting code written for a 64bit target to a 32bit
target the code is wrong then too. In fact doing:
&& TYPE_PRECISION (type) < 64
in hard coding 64bit is wrong. What happens when you have 128bit
targets, we just get into the same issue. Never say never in the
computer world, look what happen when Bill Gates said his famous words,
memory usage is way up and still raising.
Also you don't fix up the header files for size_t (and intptr_t and
ssize_t) so the warning is give false warnings in those cases. In fact
using __SIZE_TYPE__ macro will break also.
Also you don't check for cases like:
t = t1;
which is a false warning in your patch currently.