autoconf-patches
[Top][All Lists]
Advanced

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

Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."


From: Bernd Schmidt
Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Sun, 31 Dec 2006 02:59:04 +0100
User-agent: Thunderbird 1.5.0.9 (X11/20061229)

Eric Blake wrote:

/* The maximum and minimum values for the integer type T.  These
   macros have undefined behavior if T is signed and has padding bits.
   If this is a problem for you, please let us know how to fix it for
   your host.  */
#define TYPE_MINIMUM(t) \
  ((t) (! TYPE_SIGNED (t) \
        ? (t) 0 \
        : TYPE_SIGNED_MAGNITUDE (t) \
        ? ~ (t) 0 \
        : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
#define TYPE_MAXIMUM(t) \
  ((t) (! TYPE_SIGNED (t) \
        ? (t) -1 \
        : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))

I must admit I don't know what an integer with padding bits would look like. Can someone check what the C standard has to say about the bit-not operator? According to what GCC currently does, there is no integer overflow anywhere in this code: bit-not expressions never overflow, and a integer shift of -1 by (sizeof - 1) bits does not change the sign, and therefore doesn't overflow.

Even with -Woverflow, GCC does not warn when these macros are used for type "int".


Bernd




reply via email to

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