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/16/2003 00:58:28
Thus spake Greg A. Woods ("GAW> ") sometime Today...
GAW> [ On Tuesday, July 15, 2003 at 20:01:46 (+0200), Matthias Drochner wrote: ]
GAW> > In cases like the iov I'd probably prefer a union of a const and a non-const.
GAW>
GAW> That's called pointer aliasing. It's not portable nor safe, and it
GAW> disables the "const" warnings behind the compiler's back.
How is that not portable? Are there really implementations that use
non-overlapping unions?
That seems "broken".
Are there really implementations which will separate the storage of
otherwise overlapping (and identical) elements because one says "const"
and one doesn't?
That seems "broken" as well.
The idea, in case it's not clear, is that it should be possible to
selectively say "this is not const. No, really..." without having
to maintain two separate data types for what are really more or less
identical functions save that one reads and one writes. To have to
code like that tosses us back into the dark ages of Pascal and its
ilk -- and please, don't go there. I'm not terribly interested in
how every language out there should be like Pascal, or how C should
have been more structured in the first place. I'm not buying it.
Now that a fourth person has chimed in explaining the problem, perhaps
it's time to tell some of the more egregious parts of the standard to
go stick it in their ear for all the complexity to the code they would
otherwise impose.
I think standards would have been better spent on useful features,
such as the ability to declare an anonymous union or struct within
a union or struct and be able to reference its members directly
without an intervening member. or ((struct foo*) member)-> in
there. I was really disappointed that that particular construct
got dropped. It really would have simplified some of the things I've
worked on.
--*greywolf;
--
NetBSD: the power to swerve (penguins, worse than cane toads).