Re: Elimination of (more or less) all compilation warnings on OSX - Mailing list pgsql-odbc

From Tom Lane
Subject Re: Elimination of (more or less) all compilation warnings on OSX
Date
Msg-id 27047.1394124651@sss.pgh.pa.us
Whole thread Raw
In response to Re: Elimination of (more or less) all compilation warnings on OSX  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: Elimination of (more or less) all compilation warnings on OSX  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-odbc
Heikki Linnakangas <hlinnakangas@vmware.com> writes:
> It's worth noting that isspace, isdigit etc. take an "unsigned char"
> argument. The compiler won't warn if you pass a "char", so you have to
> be careful with that. In practice, I don't think it will lead to actual
> bugs on any real platform and locale, but still..

It definitely used to lead to bugs on some old platforms.  It may be
that everybody is more careful nowadays, but the POSIX spec is still
perfectly clear about it:

      The c argument is an int, the value of which the application
      shall ensure is a character representable as an unsigned char or
      equal to the value of the macro EOF. If the argument has any
      other value, the behavior is undefined.

I had my old HPUX box hacked up so that gcc would produce "subscript
is a char" warnings for unsafe usage.  It seems a bit more difficult to
get modern platforms to do that, though; people stopped exposing the
underlying flag array in the system headers ...

            regards, tom lane


pgsql-odbc by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Elimination of (more or less) all compilation warnings on OSX
Next
From: Przemyslaw Rzepecki
Date:
Subject: Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.