bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] 03-getndelim2-c89.diff


From: Bruno Haible
Subject: Re: [Bug-gnulib] 03-getndelim2-c89.diff
Date: Mon, 20 Oct 2003 22:03:10 +0200
User-agent: KMail/1.5

Paul Eggert wrote on 2003-07-25, about calling a function defined with
() argument list with at least one argument

   int foo () { return 42; }
   int bar () { return foo(13); }

> > > address@hidden:~$ gcc -Wall -W -g voidargs.c -o voidargs
> > > [no error message for line 16]
> >
> > I think that's a bug in gcc.
>
> No, it's not a bug.  See section 6.5.2.2 paragraph 2 of ISO C99:
>
>   If the expression that denotes the called function has a type that
>   includes a prototype, the number of arguments shall agree with the
>   number of parameters.
>
> voidargs1 lacks a prototype, so no diagnostic is required for line 16.
> The behavior is undefined, though (see paragraph 6 of the same section).

Strangely, some compilers nevertheless give a warning or error for this:

  - IRIX 6.5 cc gives a warning
      "foo.c", line 2: warning(1136): too many arguments in function call
        int bar () { return foo(13); }

  - HP-UX cc on ia64 HP-UX 11.23 even gives an error:
      Error 181: "foo.c", line 2 # Expected 0 argument(s) for "int foo()"; had 
1 instead.
          int bar () { return foo(13); }
                              ^^^^^^^   

Confusing...

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]