------- Additional Comments From igodard at pacbell dot net  2005-02-17 03:37 
-------
WADR, but "char" on my (x86 Linux) machine in fact signed. So I tried:
#include <cstddef>

static const char lwb = 0x80;
static const char upb = 0x7f;
static const int lwbi = lwb;
static const int upbi = upb;
static const size_t cnt = upb - lwb;
static const size_t cnti = upbi - lwbi;

int main() {
    return 0;
    }

Now I get:
~/ootbc/common/src$ c++ foo.cc
foo.cc:7: warning: integer overflow in expression
foo.cc:8: warning: integer overflow in expression

Surely after I have assigned the chars to ints and done the arithmetic in int
there cannot be an overflow, but I'm still getting a warning. And the result of
the subtraction is positive on a machine with signed chars, so it can't be the
assignment to the size_t.

Reopened - please look again.

Ivan


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20019

Reply via email to