This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: implicit declaration in C++ considered harmful
- To: "'Gabriel Dos Reis'" <Gabriel dot Dos-Reis at dptmaths dot ens-cachan dot fr>, Joe Buck <jbuck at synopsys dot com>
- Subject: RE: implicit declaration in C++ considered harmful
- From: Kaz Kylheku <kaz at cafe dot net>
- Date: Wed, 8 Apr 1998 14:17:42 -0700
- Cc: "g++ at cygnus dot com" <g++ at cygnus dot com>, "egcs at cygnus dot com" <egcs at cygnus dot com>
On Wednesday, April 08, 1998 7:31 AM, Gabriel Dos Reis
[SMTP:Gabriel.Dos-Reis@dptmaths.ens-cachan.fr] wrote:
> I think EGCS should be standard conforming and flags implicit
> declaration as an error not a warning.
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''. A C++
compiler could treat undeclared functions as being implicitly declared
int (...) provided that it emits a diagnostic.
A conforming C compiler is allowed to translate even a
*syntactically* incorrect program, provided that it diagnoses
the syntax violation!
I believe I have seen compilers that produce
an a.out executable from an empty translation unit even
after diagnosing the error!
Another good example is compilers which allow incompatible
pointer assignments to pass by with a mere warning.
This is a constraint violation that requires a diagnostic; it
is as serious as a syntax error. The warning message
serves as an adequate diagnostic, however.