Mark Dickinson <dicki...@gmail.com> added the comment:

> Well, I had memories of a weird signed/unsigned problem (issue4935) and
> I wasn't sure whether it could raise its head in the present case or
> not.

I'm 99.9% sure that it's not a problem here.  If it is a problem then it
needs to be fixed in long_hash in longobject.c as well, which uses
exactly the same code.

The relevant section of the C99 standard is 6.3.1.8, para. 1 (try
googling for 'n1256' if you don't have a copy of the standard).  The
only really nasty cases are those of the form unsigned_int +
signed_long, or more generally,

low_rank_unsigned_integer binary_op higher_rank_signed_integer

where the type of the expression depends on the relative sizes (not just
ranks) of the integer types, giving potential portability problems.  And
there are similar problems with the integer promotions (6.3.1.1, para. 2).

I guess it comes down to personal taste, but my own preference is to
leave out casts where the conversion they describe is already implied by
the C language rules, adding them back in to silence compiler warnings
if necessary.  I find it reduces noise in the code and makes the
important casts more visible, but chacun à son goût.

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5186>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to