bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] obstack.h port to IRIX 6.5 (native c89)


From: Bruno Haible
Subject: Re: [Bug-gnulib] obstack.h port to IRIX 6.5 (native c89)
Date: Fri, 14 Mar 2003 13:12:40 +0100 (CET)

Paul Eggert writes:

> 2003-03-13  Paul Eggert  <address@hidden>
> 
>       * obstack.h: (__INT_TO_PTR) [__STDC__]: Cast result to
>       (void *) to avoid diagnostic with native c89 on SGI IRIX 6.5
>       when compiling Bison 1.875's `bitset bset = obstack_alloc
>       (bobstack, bytes);'.  Problem reported by Nelson H. F. Beebe.

Hmm, the intent of __INT_TO_PTR seems to be to convert an integer to a
'char *', just like __PTR_TO_INT converts a 'char *' (not a 'void *'!)
to an integer. You see that the value of __INT_TO_PTR is assigned to
o->next_free which is of type 'char *'.

So wouldn't it be more in line with the code to leave __INT_TO_PTR
untouched and instead change obstack_finish to return a 'void *' ?

Bruno


*** obstack.h.old       14 Mar 2003 09:59:32 -0000      1.19
--- obstack.h   14 Mar 2003 12:12:15 -0000
***************
*** 123,134 ****
  #endif
  
  #ifndef __INT_TO_PTR
- #if defined __STDC__ && __STDC__
- # define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0))
- #else
  # define __INT_TO_PTR(P) ((P) + (char *) 0)
  #endif
- #endif
  
  /* We need the type of the resulting object.  If __PTRDIFF_TYPE__ is
     defined, as with GNU C, use that; that way we don't pollute the
--- 123,130 ----
***************
*** 586,592 ****
      > (h)->chunk_limit - (char *) (h)->chunk)                         \
     ? ((h)->next_free = (h)->chunk_limit) : 0),                                
\
    (h)->object_base = (h)->next_free,                                  \
!   __INT_TO_PTR ((h)->temp))
  
  # if defined __STDC__ && __STDC__
  #  define obstack_free(h,obj)                                         \
--- 582,588 ----
      > (h)->chunk_limit - (char *) (h)->chunk)                         \
     ? ((h)->next_free = (h)->chunk_limit) : 0),                                
\
    (h)->object_base = (h)->next_free,                                  \
!   (void *) __INT_TO_PTR ((h)->temp))
  
  # if defined __STDC__ && __STDC__
  #  define obstack_free(h,obj)                                         \




reply via email to

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