I thought someone said they were required in C99. However, the
discussion was about warnings---I simply assumed that any C++
compiler worth its salt would *warn* about implicit function
declarations, since it is such an obvious source of error.
Apparently, as Bjarne pointed out, I was being overly
optimistic.
I don't, it isn't well formed. Calling a variadic without a
declaration in scope invokes our old friend undefined
behaviour. That's why the compiler is required to issue a
diagnostic in conforming mode.
CAlling a variadic function without a declaration in scope
invokes undefined behavior. Which means that anything the
compiler does is fine. No diagnostic required. (FWIW: I did
use a C compiler once which generated bad code in such
cases---it used different calling conventions for variadic
functions than for normal functions. Of course, it was for
embedded systems in a free standing environment, with almost no
standard library, so previously existing code wasn't an issue.)
I wasn't commenting on the code, I was pointing out that by
default gcc (like most other C compilers) isn't a conforming C
compiler, you have to tell it to use a conforming mode.
IMHO, this is one warning that should be on by default. It's
been how many years now that function prototypes exist?
The fact that C only requires a diagnostic and the compiler is
free to carry on and produce an executable is one of the many
reasons I prefer C++ to C!
There's actually no difference between C and C++ in this regard.
In the case of undefined behavior, anything goes. In cases
where a diagnostic is required, anything the implementation
documents is a diagostic (and gcc/g++ documents that all
messages issued by the compiler can be considered diagnostics in
the sense of the standard), and once the diagnositic is issued,
what happens next is undefined. As in undefined behavior: most
compilers will try to give a more or less readable message, and
not generate an object file, in the case of an error. But most
will also consider at least some warnings as "diagnostics", and
generate code despite what the standard says is an error, and a
compiler which just output a "?" and reformatted your hard disk
would be fully conforming (but probably not a large success
commercially).
(Note too that a compiler is allowed to issue a diagnostic even
when no error is present. So a compiler which always output a
"?", and always generated an object file with something in it,
would also be fully conforming, as long as the contents of the
object file were correct when there was no error.)