[Bug c/18411] Warning not legitimate

joseph at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 10 01:41:00 GMT 2004


------- Additional Comments From joseph at codesourcery dot com  2004-11-10 01:41 -------
Subject: Re:  Warning not legitimate

On Wed, 10 Nov 2004, manus at eiffel dot com wrote:

> I believe we do not have the right definition of unspecified behavior. Going 

We're talking about undefined behavior (e.g. your computer, or the whole 
universe, may blow up) rather than unspecified (bounded variation on what 
may happen).


> extern void f();

> Knowing that actually `f' has been declared in some other module as:
> extern void f(char){...}

Those types are incompatible, 6.7.5.3#15, so you have undefined behavior 
by 6.2.7#2.  In that case - if the compiler can see both the declaration 
and definition in different translation units at once - it is compile-time 
undefined (a property of the program, rather than of some execution path, 
is undefined), so the program can be rejected.  But when compiling only 
the translation unit with the unprototyped declaration, it's possible that 
(a) the call through the cast pointer is never executed, (b) the real 
definition is of a compatible type e.g. void f(void) { ... } so there is 
only undefined behavior on execution, not compilation.  What is true is 
that given the first translation unit with call through a cast to an 
incompatible type, the behavior on execution of the call is guaranteed to 
be undefined if the behavior on translation wasn't already.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18411



More information about the Gcc-bugs mailing list