Homer nods.
Kids these days!
void foo( int (*f)() )
{
f(1);
f(1, "2" , 3.0);
}
https://godbolt.org/z/s6e5rnqv9If you compile with -std=c23, both gcc and clang will throw an error ( (*f)() is now the same as (*f)(void) )
You can write a function declaration that's inconsistent with its definition in another translation unit. Declaring the function in a shared header file avoids this.
You can use an old-style declaration that doesn't specify what parameters a function expects. Don't do that. Use prototypes.
You can use a cast to convert a function pointer to an incompatible type, and call through the resulting pointer. Don't do that.
You can call a function with no visible declaration if your compiler overly permissive or is operating in pre-C99 mode. Don't do that.
This article is exclusively about undefined behaviour. "Bad code" is already baked into the assumptions of the article.
I discussed some of the technical issues behind the article. If you disagree with anything I wrote, please say so.
I'm not even saying that the issues discussed in the article aren't useful, just going into how likely they're likely to be encountered in practice.
Itanic had variable-sized register windows, plus extra tag bits for NaT ("not a thing") placeholder values. If you didn't set one of the argument registers the callee might trap in unexpected ways when it touches the register garbage.
The only other ISA I know of that did something similar was the Am29000
The Am29000 modeled it in an interesting way though:
The register file consisted of 128 global registers but the instruction encoding allowed to specify an "indirect register index" mode where the operand register was computed from the content of gr1 plus an offset. Thus gr1 acted as a "register window stack pointer". I _think_ such a computed register index would then be used to index into a separate register file for locals (and arguments etc) but I'm not sure.
Anybody here is familiar with this quite old ISA?
(I'm really interested in the richness of the CPU design space, the history of which is fascinating)
Itanium? Stone age