On Thu, Mar 04, 2010 at 05:26:02PM -0500, Greg A. Woods wrote: > > No such luck, at least not until C grows a stronger type system. See > > for example strchr(3). > > I don't think a stronger type system would really change this issue > fundamentally unless it was one which was so radical as to change the > entire language -- All that may really be needed is a new kind of > qualifier, one that tells the compiler a return value (or other internal > variable) has the same "const" status as some given input parameter > ("const_if_{parameter-name}_const" or some such similar nonsense).
That *is* a stronger type system, one with parametric polymorphism for type qualifiers. > While strchr()'s interface, and that of strrchr() of course, are indeed > excellent examples this issue, the use of __UNCONST() within their > implementation to hide silly warnings that might be encountered by > compiling their implementations doesn't really "fix" anything except the > silly warnings. The code _must_ do what it _should_ not do. :-) Well right... > And so I think what I said about __UNCONST() being unnecessary > remains. ...but that makes it necessary. At least given the concept of "necessary" that I'm familiar with :-) -- David A. Holland dholl...@netbsd.org