octave-maintainers
[Top][All Lists]
Advanced

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

Re: 'noreturn' warning in libcruft


From: Rik
Subject: Re: 'noreturn' warning in libcruft
Date: Tue, 07 Aug 2012 09:45:44 -0700

On 08/07/2012 09:26 AM, Michael Goffioul wrote:
On Tue, Aug 7, 2012 at 5:22 PM, Rik <address@hidden> wrote:
8/7/12

All,

When compiling libcruft/misc/f77-fcn.c I get the following warning:

../../octave-dev/libcruft/misc/f77-fcn.c: In function ‘xstopx_’:
../../octave-dev/libcruft/misc/f77-fcn.c:63: warning: function declared
‘noreturn’ has a ‘return’ statement

If I look in libcruft/misc/f77-fcn.h I find the following prototype:

extern CRUFT_API F77_RET_T
F77_FUNC (xstopx, XSTOPX) (F77_CONST_CHAR_ARG_DECL
                           F77_CHAR_ARG_LEN_DECL) GCC_ATTR_NORETURN;

The 'noreturn' attribute is being explicitly set for this function so that
seems okay.

The actual function is

F77_RET_T
#if defined (F77_USES_CRAY_CALLING_CONVENTION)
F77_FUNC (xstopx, XSTOPX) (octave_cray_ftn_ch_dsc desc)
#elif defined (F77_USES_VISUAL_FORTRAN_CALLING_CONVENTION)
F77_FUNC (xstopx, XSTOPX) (const char *s, int slen)
#else
F77_FUNC (xstopx, XSTOPX) (const char *s, long slen)
#endif
{
#if defined (F77_USES_CRAY_CALLING_CONVENTION)
  const char *s = desc.const_ptr = ptr_arg;
  unsigned long slen = desc.mask.len;
#endif

  f77_exception_encountered = 1;

  /* Skip printing message if it is just a single blank character.  */
  if (s && slen > 0 && ! (slen == 1 && *s == ' '))
    (*current_liboctave_error_handler) ("%.*s", slen, s);

  octave_jump_to_enclosing_context ();

  F77_RETURN (0)
}

So the function is declared 'noreturn' and yet has a return statement.  The
function before the return, octave_jump_to_enclosing_context(), does indeed
do a longjmp so it seems like the F77_RETURN(0) can just be eliminated from
the code.

Any objections to that deletion?

Deleting it would assume that GCC_ATTR_NORETURN is always defined properly. Would it be a problem to leave it in place?
Leaving the code in place is what provokes the warning that I am trying to silence.  Note that regardless of whether GCC_ATTR_NORETURN is declared for this function, the particular line of code F77_RETURN(0) will never be executed.  The noreturn attribute is merely warning us that we're being redundant since there is no way to get to the return statement because the longjmp in octave_jum_to_enclosing_context() will always intervene.

--Rik

reply via email to

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