Subject: Re: toolchain/22118: make won't compile with -Wcast-qual
To: NetBSD Toolchain Technical Discussion List <tech-toolchain@NetBSD.org>
From: Greywolf <greywolf@starwolf.com>
List: tech-toolchain
Date: 07/17/2003 12:34:01
Thus spake Greg A. Woods ("GAW> ") sometime Today...
GAW> Furthermore w.r.t. string constants as initializers in particular:
GAW>
GAW> Even though as Ben has shown ISO C is at odds with GCC w.r.t. string
GAW> constants in expressions vs. intializers, it's irrelevant. GCC is the
GAW> most commonly used C compiler these days and it (currently) uses "const
GAW> char *" as the type for string constants in initializers so _portable_
GAW> code must assume this is true even if the ISO C Standard says it is not.
In short, the conversation has gone like this:
Before: "Well, I don't have standard handy, but I believe it says this..."
[Standard is quoted, chapter and verse...]
After: "Well, nobody follows the standard anymore, and everyone uses GCC,
so the standard is irrelevant."
How convenient. I'm sorry to be so caustic here, but I'm noting a pattern,
and it's getting old.
I would tend to assume no such animal whatsoever in the course of programming,
for I believe that would fall under the description of "unwarranted
chumminess with the compiler", as described in K&R.
"const" causes more headaches than it is supposed to solve, to my even
as-yet unjaded eye. If strings are to be placed into RO storage, great.
If you're going to write to them, common sense would dictate copying them
into writable storage and operating on them from there. If you have
routines which will both potentially read from and write to the same spot,
they should not even be HINTED at as being RO. If you're going to do
otherwise, the point of that exercise is probably a thesis for a Ph. D.
in Pedantry.
People who code using common sense with a bent toward performance tend to
produce better code than the ones who have nothing better to do than
pretend to be/listen to language lawyers (no, this is not a directed
statement or an attack. It's an observation I have made over the years).
--*greywolf;
--
NetBSD: More Nines.