This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients LambertDW, Rhamphoryncus, chemacortes, jcea, mark.dickinson, pitrou, rhettinger
Date 2009-02-12.11:54:23
SpamBayes Score 2.1970569e-05
Marked as misclassified No
Message-id <1234439666.1.0.259140408986.issue5186@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2009-02-12 11:54:26mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, jcea, chemacortes, Rhamphoryncus, pitrou, LambertDW
2009-02-12 11:54:26mark.dickinsonsetmessageid: <1234439666.1.0.259140408986.issue5186@psf.upfronthosting.co.za>
2009-02-12 11:54:24mark.dickinsonlinkissue5186 messages
2009-02-12 11:54:23mark.dickinsoncreate