Jim Meyering <[EMAIL PROTECTED]> writes:

> Is there a patch yet to make gcc suppress that warning?

Sorry, not yet.  Other things are on my plate....

> -      unsigned int n1 = n0 + 1;
> +      /* FIXME: technically, the type of n1 should be `unsigned int',
> +      but that evokes an unsuppressible warning from gcc-4.0.1 and
> +      older.  If gcc ever provides an option to suppress that warning,
> +      revert to the original type, so that the test in xalloc_oversized
> +      is once again performed only at compile time.  */
> +      size_t n1 = n0 + 1;

That doesn't look quite right in general: suppose size_t is narrower
than unsigned int?  Admittedly it's a theoretical problem, but we
might as well do it right if it's easy.

Also, I'd rather not penalize all compilers just because GCC is busted.

Personally I'd rather leave the code alone and filter out the messages
some other way.  But if they really bother you how about this instead?

   #if __GNUC__
   # include "size_max.h"
   #endif
   ...
   #if __GNUC__ && UINT_MAX < SIZE_MAX
       /* FIXME comment, as above.  */
       size_t n1 = n0 + 1;
   #else
       unsigned int n1 = n0 + 1;
   #endif

That way, non-GCC compilers can have the improved performance.

This will cause quotearg to depend on the size_max module, but that's
a lightweight module so it should be OK.


_______________________________________________
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib

Reply via email to