implicit declaration in C++ considered harmful
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Thu Apr 9 18:29:00 GMT 1998
> The C and C++ standards don't distinguish errors and warnings,
> though I say this with somewhat less than full confidence because
> I'm not as familiar with the C++ draft as with the C standard.
>
> Both types of messages qualify as ``diagnostics''.
C++ is the same, here.
> A C++ compiler could treat undeclared functions as being implicitly
> declared int (...) provided that it emits a diagnostic.
Sure it could. I think Joe made his point: even though g++ is
currently compliant (in this respect), producing an error would be
also compliant.
The real question is which one is more desirable.
> A conforming C compiler is allowed to translate even a
> *syntactically* incorrect program, provided that it diagnoses the
> syntax violation!
Right. This doesn't mean the compiler *has* to produce a program from
incorrect source :-) It may provide some non-standard extensions,
whose usage it needs to diagnose. Users of these extensions would
expect that they get a working program.
The question is whether assuming implicit declarations for global
functions is a useful extension. I agree with Joe that it isn't.
Regards,
Martin
More information about the Gcc
mailing list