emacs-devel
[Top][All Lists]
Advanced

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

FIXNUM_OVERFLOW_P on amd64


From: Francesco Potorti`
Subject: FIXNUM_OVERFLOW_P on amd64
Date: Mon, 04 Dec 2006 12:48:39 +0100

On gcc (GCC) 4.1.2 20061028 (prerelease) (Debian 4.1.1-19)

I get this:

gcc -c -D_BSD_SOURCE   -Demacs -DHAVE_CONFIG_H   -I. 
-I/home/pot/gnu/emacs-22.0.91/src -D_BSD_SOURCE  -g -O2 -Wno-pointer-sign  
editfns.c
editfns.c: In function 'Fuser_uid':
editfns.c:1317: warning: comparison is always false due to limited range of 
data type
editfns.c:1317: warning: comparison is always false due to limited range of 
data type

The relevant line is:
  return make_fixnum_or_float (geteuid ());

which expands to:
  return (((long)(geteuid ()) > (((long) 1 << ((64 - 3) - 1)) - 1)
           || (long) (geteuid ()) < - ((long) 1 << ((64 - 3) - 1)))
          ? make_float (geteuid ())
          : (((long) ((long)(geteuid ()))) << 3));

in lisp.h:
#define make_fixnum_or_float(val) \
   (FIXNUM_OVERFLOW_P (val) \
    ? make_float (val) \
    : make_number ((EMACS_INT)(val)))

#define FIXNUM_OVERFLOW_P(i) \
  ((EMACS_INT)(i) > MOST_POSITIVE_FIXNUM \
   || (EMACS_INT) (i) < MOST_NEGATIVE_FIXNUM)

#define MOST_POSITIVE_FIXNUM    (((EMACS_INT) 1 << (VALBITS - 1)) - 1)


So the problem apparently is that gcc realises that taking geteuid(),
stretching it to long and then comparing it with something bigger that
what geteuid() possibly can be is a no-op.  This is what is intended, in
fact.  To remove the warning, I tried to change the definition of
FIXNUM_OVERFLOW_P in lisp.h by adding a precondition like this:

#define FIXNUM_OVERFLOW_P(i) \
  (sizeof(i) >= sizeof(EMACS_INT) \
   && ((EMACS_INT)(i) > MOST_POSITIVE_FIXNUM \
       || (EMACS_INT)(i) < MOST_NEGATIVE_FIXNUM))

But nothing changed: the warning is still there.  While trying to find a
way to solve the problem, I realised that the make_fixnum_or_float is a
macro doing multiple evaluations of its argument, and editfns.c calls it
with a function call as an argument, which is generally not a good thing.




reply via email to

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