develooper Front page | perl.perl5.porters | Postings from February 2003

Re: remaining signedness issue in Encode 1.88

Thread Previous | Thread Next
Dan Kogai
February 26, 2003 23:56
Re: remaining signedness issue in Encode 1.88
Message ID:
On Wednesday, Feb 26, 2003, at 14:49 Asia/Tokyo, Craig A. Berry wrote:
> With bleadperl, my C compiler complains about a line in
> encode_method() like so:
>     if (slen <= 0){
> ........^
> %CC-I-QUESTCOMPARE, In this statement, the unsigned expression "slen" 
> is being compared with a relational operator to a constant whose value 
> is not greater than zero.  This might not be what you intended.
> at line number 85 in file D0:[CRAIG.PERL.EXT.ENCODE]Encode.xs;1

Hmm.  Let's see... slen is declared  STRLEN, which is defined as 
MEM_SIZE, which is defined as Size_t, meaning (32|64)-bit unsigned 

>     if (slen <= 0){
>         SvCUR_set(dst, 0);
>         SvPOK_only(dst);
>         goto ENCODE_END;
>     }

making slen a signed integer is easy but that make gcc complain when it 
is fed to SvPV().

> it seems like it would be a good idea to protect against that even if
> it's not supposed to happen.

I do agree with that.  The question is how...

(U8 *)"Dan the Encode Maintainer";

P.S. jhi, thanks for reminding anyway

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About