andy@CSVAX.CALTECH.EDU (Andy Fyfe) (08/14/89)
With "gcc -Dx1 -c x.c", gcc gives 6 warnings about incompatible pointer types for the lines so marked. With "gcc -Dx2 -c x.c", it gives no warnings at all. (I don't see why gcc should give any warnings at all -- I don't understand why a leading "const" is bad (but only, apparently, when more than single indirection is used) -- but rms assures me that ansi says so.) #ifdef x1 typedef char type; #endif #ifdef x2 typedef char *type; #endif zero(type q) { const type p1 = q; /* can't modify p1 */ } one(type *q) { const type *p1 = q; type *const p2 = q; const type *const p = q; /* can't modify *p1, p2 */ } two(type **q) { const type **p1 = q; /* incompatible ptr types */ type *const *p2 = q; type **const p3 = q; type *const *const p = q; const type *const *const r = q; /* incompatible ptr types */ /* can't modify **p1, *p2, p3 */ } three(type ***q) { const type ***p1 = q; /* incompatible ptr types */ type *const **p2 = q; type **const *p3 = q; type ***const p4 = q; type *const *const *const p = q; const type *const *const *const r = q; /* incompatible ptr types */ /* can't modify ***p1, **p2, *p3, p4 */ } four(type ****q) { const type ****p1 = q; /* incompatible ptr types */ type *const ***p2 = q; type **const **p3 = q; type ***const *p4 = q; type ****const p5 = q; type *const *const *const *const p = q; const type *const *const *const *const r = q; /* incompatible ptr types */ /* can't modify ****p1, ***p2, **p3, *p4, p5 */ }