Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: NetBSD Toolchain Technical Discussion List <tech-toolchain@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-toolchain
Date: 07/14/2003 20:47:45
> Well except for the possibility that a void* and a char* have
> different internal representations the only a proper cast would cure

(a) char * and void * have, as I understand it, been ruled (by fiat) to
have the same size and representation.

(b) Even then, that's a bogus argument because the prototypes will
provoke the correct conversions.  (Note that my deconst() is a
prototype definition; if the ellipsis at the top doesn't brng in a
prototype for bcopy() or whatever you replace it with, you may need a
cast there.  I tend to ignore such issues, because I also use
-Wstrict-prototypes -Wmissing-prototypes.)

> However it doesn't work in general for the desired purpose

Oh?  It works for the purpose I desire it for: suppressing a certain
compiler warning in a few cases where I-the-coder know the warning is
noise, _without_ suppressing it in other cases throughout the file (as
-Wno-cast-qual or -fwritable-strings would do).

What purpose did you think it was for?

> It's no better, and not much different, than relying on the GCC "bug"
> of using "char foo[]"

This is not a bug.  char foo[] = "bar"; is not an assignment, and "bar"
is not the auto-initialized array-of-(const-)char it would be in an
rvalue context.  Try char foo[] = "bar"+0; and see what happens.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B