[Bug c/63591] be more strict when accepting parameter forward declarations
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Oct 18 23:19:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63591
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Summary|No syntax error yielded for |be more strict when
|semicolons inside a |accepting parameter forward
|function proto, instead |declarations
|code with memory corruption |
|can be created |
--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Kjetil Matheussen from comment #3)
> I didn't know about this gnu extension. But regardless, shouldn't gcc
> complain when the proto doesn't match the function itself?
Unfortunately, there is [*] too much old code that would break if we did so.
But you can use -Wstrict-prototypes.
[*] or there was, perhaps we should revisit adding -Wstrict-prototypes to
-Wall. But to do that we need someone that will propose such a patch, fix any
failing testcases in the testsuite and convince the maintainers.
> Also, although I don't understand how this extension works from the
> documentation, I have a feeling that there should have been a warning or
> error when compiling code calling "afunction" as well?
>
> int main(){
> return afunction(5, NULL);
> }
>
> (this compiles just fine)
This is because int foo(); is not a prototype (you can call it with foo(5,5)).
You need -Wstrict-prototypes.
More information about the Gcc-bugs
mailing list