guile-devel
[Top][All Lists]
Advanced

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

Re: Fixing num2integral.i.c's warnings (a proposal).


From: Dirk Herrmann
Subject: Re: Fixing num2integral.i.c's warnings (a proposal).
Date: Tue, 25 Sep 2001 00:15:43 +0200 (MEST)

On Wed, 19 Sep 2001, Rob Browning wrote:

> On some systems, some of the functions generated my num2integral.i.c
> are going to generate warnings that can't be avoided with the current
> approach.  That's because they have a test (see below) for
> "sizeof(ITYPE) < sizeof(scm_t_signed_bits)" just before a
> SCM_FIXABLE(n) test.
> 
> The problem is that since the sizeof tests can't be performed at
> compile time, the compiler complains about the SCM_FIXABLE(n) test
> always being true (which for say, ITYPE == short, it will be), and
> aside from complaining, will also generate useless code.

Are you sure about the useless code?  A good compiler should not produce
any code in such a situation.

> Since the compiler can't compute sizeof(X) at compile time and
> automagically rewrite our conditional, I propose we fix up configure
> to generate a set of variables of the form GUILE_SIZEOF_FOO where FOO
> is one of the itypes, and also a variable named
> GUILE_SIZEOF_SCM_T_SIGNED_BITS (feel free to suggest other names,
> though these don't need to be public).

If these are not public, I'd suggest to simply remove the GUILE_ prefix
from them.  But, see below.

> Then INTEGRAL2NUM can be rewritten to conditionally compile code based
> on a test like this
> 
>   #if GUILE_SIZEOF_ITYPE < GUILE_SIZEOF_SCM_T_SIGNED_BITS
>     ...
> 
> and just before #including num2integral.i.c, you'd just add an
> appropriate "#define SIZEOF_ITYPE GUILE_SIZEOF_FOO" along with the
> #define for ITYPE.
> 
> This would not only fix the warnings, but should remove some unused
> code from some of the conversions.

Hmmm.  I'm typically much in favor of getting rid of compiler warnings.  
Normally I use -Wall plus -W when compiling guile - which still gives a
lot of open warnings, try it!  However, I wonder if it really makes sense
to remove any warning - no matter what it costs.  As I said above, it
seems not very likely that a recent compiler will produce dead code.  And,
just for the benefit of getting rid of these warnings, I feel the above
scheme will complicate things more than it helps.

Best regards
Dirk Herrmann




reply via email to

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