blambert@lotus.com (Brian Lambert) (07/21/90)
Hi: I am using VAX C (latest version, 3.something) and I ran into this weird problemthe other day. As it turns out, the following code does not generate a compilation warning: typedef struct { long foo; } A; typedef struct { short foo, bar; } B; void x(B *b); main() { A a; B b; x(&a); /* does not generate a warning */ x(&b); ... This same code generated a compiler warning using -W1 in MSC 6.0. The manual says that since the arguments are "assignment compatible" an automatic conversion is provided. I don't want this - is there a way to disable this less-than-useful functionality? Thanks, brian lambert --- nothing interesting in here
karl@haddock.ima.isc.com (Karl Heuer) (07/21/90)
In article <1990Jul20.184748.4362@lotus.com> blambert@lotus.UUCP (Brian Lambert) writes: >void x(B *b); > A a; > x(&a); /* does not generate a warning */ File a bug report. The arguments are *not* assignment compatible. "3.3.4 Conversions that involve pointers (other than as permitted by the constraints of 3.3.16.1) shall be specified by means of an explicit cast." I think this should have been under Constraints rather than Semantics; as it stands, the diagnostic appears to be optional. Is there any value in *not* flagging this as an error? (Btw, this same clause covers pointer-vs-int collisions.) Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
tada@athena.mit.edu (Michael J Zehr) (07/22/90)
In article <17130@haddock.ima.isc.com> karl@kelp.ima.isc.com (Karl Heuer) writes: >In article <1990Jul20.184748.4362@lotus.com> blambert@lotus.UUCP (Brian Lambert) writes: >>void x(B *b); >> A a; >> x(&a); /* does not generate a warning */ > >File a bug report. The arguments are *not* assignment compatible. >Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint No, don't file a bug report. this is documented behavior for the Vax C compiler (which obviously isn't fully ansi-compatible yet). try cc /standard=portable instead. that will warn about pointers to incorrect types, or different levels of indirection (like char * vs. char **), plus a number of other warnings that are not reported by default. -michael j zehr
walter@hpcllca.HP.COM (Walter Murray) (07/23/90)
Karl Heuer writs: > In article <1990Jul20.184748.4362@lotus.com> blambert@lotus.UUCP (Brian Lambert) writes: >>void x(B *b); >> A a; >> x(&a); /* does not generate a warning */ > File a bug report. The arguments are *not* assignment compatible. > "3.3.4 Conversions that involve pointers (other than as permitted by the > constraints of 3.3.16.1) shall be specified by means of an explicit cast." > I think this should have been under Constraints rather than Semantics; as it > stands, the diagnostic appears to be optional. I don't think the diagnostic is optional. The code above violates this CONSTRAINT from 3.3.2.2: "Each argument shall have a type such that its value may be assigned to an object with the unqualified version of the type of its corresponding parameter." It's a moot point, of course, if the compiler doesn't claim to conform to the standard. Walter Murray ----------
karl@haddock.ima.isc.com (Karl Heuer) (07/25/90)
In <7330027@hpcllca.HP.COM> walter@hpcllca.HP.COM (Walter Murray) writes: >I don't think the diagnostic is optional. The code above violates this >CONSTRAINT from 3.3.2.2... Hmm. I'm moving this issue to comp.std.c. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint