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/12/2003 16:27:39
> Copying const qualified storage to non-const qualified storage is the
> only safe and truly portable way you can discard const.

This depends on what you mean by "safe and truly portable" and "discard
const".

I have no problem with using deconst() for something like iov_base when
used with writev(), because writev _won't_ modify the pointed-to
storage.  (If the interface were designed to be used const-poisoned,
writev would use a different struct from readv.)  How is doing this
unsafe or nonportable?  Or does it not count as discarding const?

> Since a "volatile" and "const" make no real sense togethr in a cast

...huh?  volatile const makes perfect sense: the object must be read
exactly as the source implies, but the source promises it will not
write to it through that path.  A device register is a typical example.
A pointer to a value modified by a signal handler might be another (the
handler, obviously, would have to use a non-const reference to the
storage to do the modification.)

>         char *magic = (volatile char *) MAGIC;

Discarding volatile is just as verboten as discarding const.

/~\ 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