[Top][All Lists]

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

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

From: Paul Eggert
Subject: Re: [Bug-gnulib] 03-getndelim2-c89.diff
Date: 20 Oct 2003 16:50:51 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Bruno Haible <address@hidden> writes:

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

> 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); }

As I read the standard, a conforming C compiler is not allowed to
reject the above-quoted program, unless it can prove that 'bar' must
be executed when the program runs (and in that case the program must
have undefined behavior).  It's a bit like this program:

int bar { return 1 / 0; }

So possibly this is a bug in HP-UX cc; or perhaps you need to pass an
option like GCC's "-ansi" to HP-UX cc.

Anyway, some compilers do issue warnings for this kind of bug, and
these warnings are often useful; but we can't rely on them.

reply via email to

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