Arsen Arsenović <ar...@aarsen.me> writes:

> Good.  The above code is nonsense, the chances that foo will be
> incorrectly called are high.

Yet lint (or scrutiny, as should be performed with any declaration,
implicit or not) makes sure that does not happen.

> What is this meant to produce?

It was just an example.  I'm not allowed to show any real code.

> This is, at best, a "works by coincidence", rather than being code
> anyone should be writing.

See what I said about being the judge, jury and executioner.

  (BTW, I thought implicit int was being discussed, not implicit
   function declarations, but here goes.)

The same problems will appear with _any_ extern declaration.  If you
remove implicit function declarations, people will simply paste:

  extern int foo ();

above the code which no longer compiles.
Or, if you force everyone to use prototypes,

  extern int foo (char *);

You will not be able to diagnose whether or not this declaration is
correct, because the definition will lie in another translation unit.
Except that in this case, no diagnostic will be issued at all when
the declared function is called.

The only place where you can truly fix mismatched declarations is the
linker (or collect2?)  GCC proper cannot do anything about it.

> Such code is already written, when building it, pass -fpermissive.
> You benefit from the error otherwise.
>
> (and no, this isn't an issue of style, the code in question *does not*
> convey sufficient information for the compiler to always do the right
> thing)

It does on reasonable machines for which the code was written.  I gave
two examples.  Perhaps the 386 is another.

Reply via email to