Optional vs. required diagnostics
Walter Murray
walter at hpcllca.HP.COM
Thu Jul 26 02:49:13 AEST 1990
Karl Heuer asks:
> Must the following code fragments generate a diagnostic?
> /* [0] */ double *p; int x; p = &x;
> /* [1] */ void f(double *p); int x; f(&x);
I believe both fragments require diagnostics.
Maybe I'm missing something here, but it seems to me the key
section of the standard is 3.3.16.1, Simple Assignment. It
contains a single constraint, stating that in a simple assignment
one of five conditions must hold. Your fragment [0] contains
a simple assignment for which none of those conditions hold, so
it violates the constraint and must be diagnosed by a conforming
compiler. Anyone who claims that a diagnostic is not required
should say which of the five conditions does hold.
Likewise, fragment [1] violates a constraint in 3.3.2.2, because
the assignment would be illegal. It's 3.3.16.1 that tells us
the assignment is illegal.
As I see it, the clause in 3.3.4 beginning, "Conversions that involve
pointers ..." could be deleted without changing the standard. It is
only serving to introduce the following four paragraphs.
Walter Murray
----------
More information about the Comp.std.c
mailing list