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/16/2003 03:08:27
>>> const-qualified storage can never be portably de-const-ified,
>> No. But pointer-to-const can be portably converted to
>> pointer-to-nonconst.
> That's called pointer aliasing and it bypasses the very checks proper
> use of "const" is intended to allow.
Well, it's not what I think of pointer aliasing as being, but that's by
the way. I consider it a lesser price than removing -Wwrite-strings or
adding -fwritable-strings, as it bypasses those checks only in the
cases where I specifically choose to have it do so, rather than all
cases.
> I fully realize there's no portable way not to have string constants
> stored in const-qualified storage,
Check into that; as I mentioned, I believe you're wrong. They may be
read-only, but making them const is a gccism, not Standard C.
> All string constants _may_ be stored in read-only storage and thus to
> use them in portable code it's necessary (at least if you want your
> code to be portable and strictly standards compliant) to always copy
> string constants to writable storage before passing/assigning a
> pointer to the latter via/to any pointer which does not point to
> const-qualified storage.
You appear to believe that it is a standards violation to merely _have_
a pointer-to-non-const pointing to read-only storage, regardless of
whether you actually try to store through it.
I do not believe this, and will not until you (or someone) cites
chapter and verse demonstrating it.
> If you're going to use pointer aliasing to avoid compiler warnings
> then you may as well simply not even try to use "const" in the first
> place
This is much too black-and-white a view. Using const does give me
valuable warnings despite my specifically shutting them off in a few
carefully chosen places. This statement of yours amounts to saying "if
you don't use this aid everywhere you might as well use it nowhere",
which is...ludicrous, and if you seriously believe it we should stop
talking now.
Actually, we should stop talking now anyway, as we're just going around
and around the same claims and counter-claims.
This will be the end of this thread from me unless you come up with
something more than a reiteration of the same tired old claims I've
responded to time and again.
/~\ 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