C89's Undefined Behavior: GCC and Clang Disagree on a 30-Year-Old Ambiguity

An ambiguity in c89 which will never be fixed

A C89 standard ambiguity regarding implicit function declarations remains unresolved, as GCC and Clang interpret the 'innermost block' phrase differently. The issue arises in code like `int f(int f[sizeof(f())]);`, where the implicit declaration of `f` may land in function prototype scope, causing a redeclaration conflict. Clang accepts the code, while GCC rejects it, and the standard's silence on the matter means the behavior will never be clarified since C99 removed the feature.

i am begging people to stop using c89. please.
  1. chasil

    I just rebuilt a core program that talks to my UNIVAC OS2200 CITA and my VAX ACMS from Linux.

    I built this first as a 32-bit binary, and there was noise that I had to cut with a substr function.

    In the rebuilding with my MinGW 64-bit Windows cross compiler on Oracle Linux, I had to mine function prototypes out of all the code for exactly this reason.

    'for those unaware: c89 has a cool "feature" where, if you try to call a function which doesn't exist, rather than erroring out, the function is implicitly declared as a function with unspecified parameters returning int.'

    I'm not testing this, because that is agony.

    I'm leaving them a working build, and retiring this month.

    This code was written by the living and the dead, and my stewardship is finished. I do not envy the poor soul who must test this.

    It was ashes when I excavated it myself. A hat tip to those who have gone before.

  2. bellowsgulch

    All the weird stuff I have read about C or C++ doing over the years could be summed up with “Well… don’t do that.”

    Like almost without fail. I can’t even think of how you’d end up in a scenario like this because a compiler would complain before letting you use an undefined implicit declaration.

  3. flohofwoe

    I'm not sure what the "which will never be fixed" part in the title is about, the problem was clearly fixed in C99 by removing the entire "misfeature" from the standard (e.g. GCC and Clang do error out both in C and C++ compilation mode).

    My guess is that the implicit declaration was a leftover from a C predecessor (B?) and kept in C to simplify programming in hybrid B/C environments. Just a guess though.

  4. guenthert

    "because the problematic behavior was removed from the standard over 27 years ago, we'll never have closure on what the intended interpretation is."

    Obsolete standard turns out to be insufficiently strict, news at 11.

  5. benj111

    Visit the homepage https://sebsite.pw/

    That's a nice bit of understated 90s design right there

More from this day

2026-08-14