Source-Changes-D archive

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

Re: CVS commit: src/crypto/dist/openssl/apps

On Wed, Apr 15, 2009 at 09:11:01AM +0700, Robert Elz wrote:
 >   | The ctype functions are often implemented as #defines that index arrays,
 >   | so if the argument is 'char' it is very likely to index off the front
 >   | which leads to an unexpected result or core dump.
 > Yes, the "undefined behaviour" from the man page...
 >   | I suspect the gcc warning here is present precisely to detect bad use
 >   | of the ctype functiuons.

More accurately, our <ctype.h> is rigged so it will trigger this
warning upon (some) improper/undefiend uses of ctype functions. Most
other systems do not do this (many also intentionally tolerate/handle
negative arguments) which is why 3rd party software triggers the
warning so much.

 > Very likely true, but it is still dumb, as in C "char" is just an int
 > type, outlawing indexing by char is no more sane than outlawing indexing
 > by short or int.

It took me a while to realize it... but the reason for that warning is
that plain char might be either signed or unsigned, so if one moves
code that uses plain char as an array index to the opposite kind of
platform, things are fairly likely to break.

The warning doesn't appear if you explicitly use either signed or
unsigned char.

David A. Holland

Home | Main Index | Thread Index | Old Index