[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SCM_POSFIXABLE(-1) fails with MSVC++ 6.0
From: |
Lars J. Aas |
Subject: |
SCM_POSFIXABLE(-1) fails with MSVC++ 6.0 |
Date: |
Thu, 22 Aug 2002 15:30:52 +0200 |
User-agent: |
Mutt/1.3.24i |
Hi guys,
I've been compiling Guile 1.5.6 with MSVC++ on Cygwin.
Today I found a strange bug in my modified version, that
made this test fail:
(if (= ( { scm_long2num(-1) } ) -1)
(display "there is no bug\n")
(display "there is a bug!\n"))
I tracked the problem down to SCM_POSFIXABLE(-1) failing
with MSVC++, causing scm_long2num(-1) to create a bignum
instead of an integer, but succeeding on GNU/Linux w/gcc.
I don't see immediately why it should happen - it looks
like a compiler bug to me.
Here is a fairly minimal example. If anyone has access to
MSVC++ and can understand why it fails and how to correct
the SCM_POSFIXABLE macro to work with MSVC++, it would be
very nice, and ought to go into the Guile sources too.
Lars J
#include <stdio.h>
#include <limits.h>
typedef signed long scm_t_signed_bits;
#ifdef CHAR_BIT
# define SCM_CHAR_BIT CHAR_BIT
#else
# define SCM_CHAR_BIT 8
#endif
#ifdef LONG_BIT
# define SCM_LONG_BIT LONG_BIT
#else
# define SCM_LONG_BIT (SCM_CHAR_BIT * sizeof (long) / sizeof (char))
#endif
#define SCM_I_FIXNUM_BIT \
(SCM_LONG_BIT - 2)
#define SCM_MOST_POSITIVE_FIXNUM \
((((scm_t_signed_bits) 1) << (SCM_I_FIXNUM_BIT - 1)) - 1)
#define SCM_POSFIXABLE(n) ((n) <= SCM_MOST_POSITIVE_FIXNUM)
int
main(int argc, char ** argv)
{
fprintf(stderr, "testing through SCM_POSFIXABLE if -1 is <= %ld - ",
SCM_MOST_POSITIVE_FIXNUM);
if ( SCM_POSFIXABLE(-1) ) fprintf(stderr, "true\n");
else fprintf(stderr, "not so!\n");
fprintf(stderr, "testing directly if -1 is <= %ld - ",
SCM_MOST_POSITIVE_FIXNUM);
if ( -1 <= 536870911 ) fprintf(stderr, "true\n");
else fprintf(stderr, "not so!\n");
return 0;
}
- SCM_POSFIXABLE(-1) fails with MSVC++ 6.0,
Lars J. Aas <=