This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/70114] Incompatible implicit function declaration error when parameters actually match a prototype in another scope
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 08 Mar 2016 00:01:01 +0000
- Subject: [Bug c/70114] Incompatible implicit function declaration error when parameters actually match a prototype in another scope
- Auto-submitted: auto-generated
- References: <bug-70114-4 at http dot gcc dot gnu dot org/bugzilla/>
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).