bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] obstack uses casts as lvalues


From: Joseph S. Myers
Subject: [Bug-gnulib] obstack uses casts as lvalues
Date: Mon, 20 Oct 2003 22:41:16 +0100 (BST)

GCC is removing the casts-as-lvalues extension (to be removed for C++ in
GCC 3.4, deprecated for C in 3.4 and removed for C in 3.5).  obstack.h
uses this extension; this patch removes those uses I know of.  Tested
minimally with glibc's tst-obstack.c.

--- obstack.h.orig      2003-09-09 23:00:43.000000000 +0000
+++ obstack.h   2003-10-20 21:36:21.000000000 +0000
@@ -354,7 +354,8 @@
 ({ struct obstack *__o = (OBSTACK);                                    \
    if (__o->next_free + sizeof (void *) > __o->chunk_limit)            \
      _obstack_newchunk (__o, sizeof (void *));                         \
-   *((void **)__o->next_free)++ = (datum);                             \
+   *(void **)__o->next_free = (datum);                                 \
+   __o->next_free += sizeof (void *);                                  \
    (void) 0; })
 
 # define obstack_int_grow(OBSTACK,datum)                               \
@@ -362,14 +363,15 @@
 ({ struct obstack *__o = (OBSTACK);                                    \
    if (__o->next_free + sizeof (int) > __o->chunk_limit)               \
      _obstack_newchunk (__o, sizeof (int));                            \
-   *((int *)__o->next_free)++ = (datum);                               \
+   *(int *)__o->next_free = (datum);                                   \
+   __o->next_free += sizeof (int);                                     \
    (void) 0; })
 
 # define obstack_ptr_grow_fast(h,aptr)                                 \
-  (*((void **) (h)->next_free)++ = (aptr))
+  ((*((void **) (h)->next_free) = (aptr)), ((h)->next_free += sizeof (void *)))
 
 # define obstack_int_grow_fast(h,aint)                                 \
-  (*((int *) (h)->next_free)++ = (aint))
+  ((*((int *) (h)->next_free) = (aint)), ((h)->next_free += sizeof (int)))
 
 # define obstack_blank(OBSTACK,length)                                 \
 __extension__                                                          \

-- 
Joseph S. Myers
address@hidden




reply via email to

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