bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] readtokens bug


From: Paul Eggert
Subject: Re: [Bug-gnulib] readtokens bug
Date: 14 Jan 2003 09:32:24 -0800

Bruno Haible <address@hidden> writes:

> Jim Meyering writes:
> > How about removing the cast altogether and making it be of type
> > `unsigned char const *' instead?
> 
> This path leads to a dead end.

I agree, but there's a better way to avoid the cast, a method that I
now prefer in software that I help maintain.  Instead of this:

        return table[(unsigned char) E];

I write something like this:

        unsigned char c = E;
        return table[c];

Avoiding casts entirely catches a few more errors.  E.g., if E is
actually a pointer you'll get a compile-time error if you avoid the
cast, but typically an unchecked run-time error if you use the cast.




reply via email to

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