This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/70114] Incompatible implicit function declaration error when parameters actually match a prototype in another scope


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70114

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Mon, 7 Mar 2016, tanzx940228 at hotmail dot com wrote:

> 3.gcc.error.c
> -------------
> int main() {
>     {
>         int foo(float arg0, float arg1);
>         foo(3.0f, 4.0f);
>     }
>     {
>         foo(3.0f, 4.0f); // clang passes, gcc gets an error???
>     }
> }
> 
> This is really weird! Clang gives me a warning saying that I'm using an
> out-of-scope prototype. BUT gcc gives me an error, saying "incompatible
> implicit declaration of function âfooâ"! What happened?

An unprototyped function type is never compatible with a function 
prototype with argument types subject to the default argument promotions, 
such as float.  See C90 6.5.4.3 (reference to C90 since you're using 
implicit declarations).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]