guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unsigned char confusion


From: Greg Troxel
Subject: unsigned char confusion
Date: Tue, 11 Aug 2009 09:39:34 -0400
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.3 (berkeley-unix)

In srfi-13.c line 25222, SCM_MAKE_CHAR is called with an argument that
is an unsigned char.  This leads to:

cc1: warnings being treated as errors
srfi-13.c: In function 'string_titlecase_x':
srfi-13.c:2522: warning: comparison is always false due to limited range of 
data type
srfi-13.c:2522: warning: comparison is always false due to limited range of 
data type

This is because SCM_MAKE_CHAR (in libguile/chars.h) has a bizarre
conditional that checks the argument for < 0, and if so casts it to
unsigned char.  Otherwise it does not cast.  There is no comment that
explains what the point is.  Fairly obviously this is an attempt to
avoid sign extension during SCM_MAKE_ITAG8.  The value is then cast to
uintptr_t which is also unsigned, but sign extension would set more
bits.

So, I think the cast to unsigned char should just always be there, without the 
test.

Attachment: pgpfr5oKombS6.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]