<<< Date Index >>>     <<< Thread Index >>>

Re: Little code cleanup



On 2008-03-24 10:01:34 +0100, Ludolf Holzheid wrote:
> I suppose gcc suspects "a == 0" being a typing error and should
> actually read "a[0] == 0".

I doubt this is the reason: one gets the same warning with:

  if ((char *) a == 0)

> As long as gcc knows 'a' is an array, giving a warning seems sensible
> to me (as the programmer is supposed to know this as well, and testing
> for 'a' being zero doesn't make sense then).

No, the programmer isn't necessarily supposed to know anything. The
"a" (or "(char *) a" if you prefer) can be used as a macro argument,
where the macro can also accept null pointers and must cope with them.
So, testing that the pointer is null really makes sense here (without
this test the code would be incorrect), and the warning is just an
annoyance.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)