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: David Laight <david@l8s.co.uk>
List: tech-toolchain
Date: 07/16/2003 20:00:15
> K&R 2nd edition states quite emphatically on p. 103:
> 
>     The valid pointer operations are assignment of pointer of the same
>     type, adding or subtracting a pointer and an integer, subtracting or
>     comparing two pointers to members of the same array, and assigning
>     or comparing to zero.  All other pointer aritmetic is illegal.

But that is in the 'prose' part of the book, refer to Appendix A
section A4.4 (page 196) 'Neither qualifier affects the range of values
or arithmetic properties of the object.'

> Assigning a "const char *" variable to a "char *" variable requires a
> cast, but of course that cast discards the 'const' qualifier and thus
> the warning from '-Wconst-qual'.

If that were true it would also be an error to assign a 'char *'
value to 'const char *' variable.

Referring to K&R2 section A8.21 (page 211) we also have (right at the
bottom on the page): 'Except that it should diagnose explicit attempts
to change const objects, a compiler may ignore these qualifiers.'

Note that this says 'explicit', not 'make you have to go through hoops to'.

	David

-- 
David Laight: david@l8s.co.uk