libtool: possible candidate for attribute 'noreturn'

Charles Wilson cygwin@cwilson.fastmail.fm
Fri Sep 18 02:44:00 GMT 2009


Yaakov (Cygwin/X) wrote:
> Compiling libcanberra-0.17 (which adds tons of -W flags) with latest
> libtool and gcc-4.3.2-2:
> 
>   CCLD   test-canberra.exe
> ./.libs/lt-test-canberra.c: In function 'lt_fatal':
> ./.libs/lt-test-canberra.c:582: warning: function might be possible
> candidate for attribute 'noreturn' [-Wmissing-noreturn]
> 
> Perhaps someone can explain why only this function, and not others which
> "return" void, trigger this warning.

The "noreturn" attribute is not used to indicate that a function returns
void. The return type specification does that.

Rather, it is used to indicate that a given function might not ever
return back through the call stack (because it uses longjmp, or exit,
abort, etc.

Now, it would appear to me that the compiler is being very smart (too
smart?) here, because it is diagnosing that lt_fatal calls lt_fatal_core
with an exit_status argument of EXIT_FAILURE, and lt_fatal_core has this:

  if (exit_status >= 0)
    exit (exit_status);

So, the compiler is smart enough, even in the face of a conditional in a
called function, to know that the caller will never return.

> In any case, while I still don't understand why libtool insists on
> compiling lt-*.c with the same flags as the actual code itself,

Because we don't know what wacky compiler flags are necessary for the
wacky target environment (if on mingw the user wants to link the apps to
-lmsvcrt90, shouldn't we also link the wrapper that way? No? What if the
user has explicitly removed the usual msvcrt import lib?). If the flags
are good enough for the package being compiled, they should be good
enough for the quite simple lt-*.c.  It would almost certainly be wrong
for us to attempt to guess a better set of flags for the $host compiler
-- although maybe we should think about stripping -W* flags if $is_gcc.
Or, at the very least, strip out -Werror.

> I'll
> leave this to you to determine if and how this should be fixed.

I'm not sure. Would you mind posting this to bug-libtool@ and
referencing this thread? Let's see what Ralf, Bob, and Peter say about it.

--
Chuck

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list