This is the mail archive of the gcc-patches@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: [Patch] Conversion warnings when truncating 64-bit types (v1)


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:

size_t_ish t;
size_t_ish t1;
t = t1;

which is a false warning in your patch currently.

Thanks,
Andrew Pinski


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