octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #60316] New warnings, errors showing up during


From: Rik
Subject: [Octave-bug-tracker] [bug #60316] New warnings, errors showing up during compilation
Date: Thu, 1 Apr 2021 17:44:50 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36

Follow-up Comment #5, bug #60316 (project octave):

I just checked and re-built the libgnu directory from my copy of gnulib and
still get these warnings.  My C compiler is


gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


The warning looks conceptually right to me.  One full example is


In file included from liboctave/wrappers/intprops-wrappers.c:26:0:
liboctave/wrappers/intprops-wrappers.c: In function
‘octave_ui_multiply_overflow_wrapper’:
libgnu/intprops.h:45:55: warning: comparison of unsigned expression < 0 is
always false [-Wtype-limits]
 #define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
                                                       ^
libgnu/intprops.h:392:42: note: in expansion of macro ‘EXPR_SIGNED’
     ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b)
\
                                          ^~~~~~~~~~~
liboctave/wrappers/intprops-wrappers.c:60:10: note: in expansion of macro
‘INT_MULTIPLY_WRAPV’
   return INT_MULTIPLY_WRAPV (a, b, r);
          ^~~~~~~~~~~~~~~~~~


The code in intprops-wrapper.c is


int
octave_ui_multiply_overflow_wrapper (unsigned int a, unsigned int b,
                                     unsigned int *r)
{
  return INT_MULTIPLY_WRAPV (a, b, r);
}


In this case, the inputs are "unsigned int" so they never can be less than 0
which matches the compiler warning.

Maybe we shouldn't be calling these wrapper functions at all for "unsigned
int" objects.  Or if we must, then we can define them inline here as

+verbatim
int
octave_ui_multiply_overflow_wrapper (unsigned int a, unsigned int b,
                                     unsigned int *r)
{
  return (int) (a*b);
}


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60316>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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