bug-guile
[Top][All Lists]
Advanced

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

Re: hash.c:101: pointers are not permitted as case values


From: Dirk Herrmann
Subject: Re: hash.c:101: pointers are not permitted as case values
Date: Tue, 5 Jun 2001 10:37:09 +0200 (MEST)

On 4 Jun 2001, Marius Vollmer wrote:

> Alexander Klimov <address@hidden> writes:
> 
> > hash.c: In function `scm_hasher':
> > hash.c:101: pointers are not permitted as case values
> 
> What happens when you change the code like this:
> 
>     case SCM_UNPACK(SCM_EOL): 
>       d = 256; 
>       break;
> 
> If that helps, we will use that fix.

There's a problem with that fix.  You are not supposed to use function
calls as a case value.  The functionality of SCM_UNPACK is quite simple
with SCM_DEBUG_TYPING_STRICTNESS set to 0 or 1, but it fails, since
SCM_UNPACK calls a function when SCM_DEBUG_TYPING_STRICTNESS is 2.

A possible solution is to define a number of alternative macros, like for
example SCM_EOL_BITS (or SCM_RAW_EOL or SCM_BITS_EOL or whatever naming
scheme to be used), which represent the integer value before packing.  
However, this seems to be overkill since it is only done to fix the case
statements all over.  On the other hand, it may be the cleanest way to do
things:  We'd like to see SCM as an opaque data type, which means that it
is unclean to use SCM values in case statements anyway.

An acceptable short term solution would be to define
SCM_DEBUG_TYPING_STRICTNESS as 0 if all other possibilities lead to
problems.


It would be nice if we had a chance to declare an attribute to inhibit
implicit type conversions for certain typedefs.  It's probably an idea
that has already been thought of by for example the gcc development folks.
  #typedef intptr_t SCM \
    __attribute__ ((noimplicitconversion, enablecaselabel))
:-)

Dirk Herrmann





reply via email to

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