Hi Paul,

> In controversial areas like this, we should look to the GNU coding standards
> for advice, and they state that one shouldn't cast to void, or use
> similar measures merely to satisfy a lint checker.

Let me quote the GCS explicitly:

   "Don't make the program ugly to placate `lint'.  Please don't insert
    any casts to `void'.  Zero without a cast is perfectly fine as a null
    pointer constant, except when calling a varargs function."

Observe that:

  1) The main intent of this paragraph is not "don't insert any casts to
     'void'". It is "Don't make the program ugly to placate 'lint'."
     The reason is that 'lint' was a rarely used tool, and not a GNU tool.

     But here we are dealing with warnings from GCC, which is our _main_
     compiler, for _everyday_ use, and a GNU tool also.

  2) The second part of this paragraph
       "Zero without a cast is perfectly fine as a null
        pointer constant, except when calling a varargs function."
     is not only clearly oldish - since it is common practice nowadays
     to write NULL for the null pointer constant - but also factually
     wrong: 0 is also different from NULL as an argument of the
     'sizeof' operator.

In summary, I think you are going too far by applying this oldish paragraph
to the current situation. And it would be better to update the GCS so that
they give reasonable advice also for today's situations, otherwise they
become less and less relevant.

Bruno

Reply via email to