Please find the attached patch.

Basically, it just coerces all of the problem places to id prior to coercing it
to GSIMapVal/GSIMapKey/etc.  This fixes the problem, but I'm not sure it's the
cleanest solution.

I ran a test recently on gcc 3.4.3, using the attached simple test.c program.  
I got the following:

[EMAIL PROTECTED] heron]$ gcc -o testa test.c 
test.c: In function `main':
test.c:16: error: cast to union type from type not present in union
[EMAIL PROTECTED] heron]$ gcc -v
Reading specs from /opt/gcc/3.4.3/lib/gcc/i686-pc-linux-gnu/3.4.3/specs
Configured with: ../configure --enable-threads=posix --prefix=/opt/gcc/3.4.3
--enable-languages=c,c++,objc --disable-checking --with-system-zlib
--enable-shared --enable-__cxa_atexit
Thread model: posix
gcc version 3.4.3

It would seem that the fact that the coercion ever worked in the first place
was a bug.  

Please evaluate the patch and provide feed back.  I am going to continue
testing with both 4.1 and older versions of gcc.  Barring any objections, I
think I should check it in.

Thanks, GJC

Gregory John Casamento 
-- CEO/President Open Logic Corp. (A MD Corp.)
## Maintainer of Gorm (IB Equiv.) for GNUstep.
? gnustep-changes-for-gcc-4.1.diff
? back/Source/libgnustep-back-010Info.plist
? base/SSL/SSL.bundle
? base/SSL/config.h
? base/SSL/config.log
? base/SSL/config.mak
? base/SSL/config.status
? base/SSL/shared_debug_obj
? base/Source/GSConfig.h
? base/Source/Info-gnustep.plist
? base/Source/mframe.h
? base/Source/Additions/shared_debug_obj
? base/Source/unix/shared_debug_obj
? gui/Printing/GSLPR/GSLPR.bundle
? gui/Printing/GSLPR/shared_debug_obj
? gui/Source/Info-gnustep.plist
? gui/Source/config.h
Index: back/Source/gsc/GSContext.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/back/Source/gsc/GSContext.m,v
retrieving revision 1.15
diff -c -r1.15 GSContext.m
*** back/Source/gsc/GSContext.m	9 Jul 2005 00:10:08 -0000	1.15
--- back/Source/gsc/GSContext.m	7 Oct 2005 03:44:16 -0000
***************
*** 94,100 ****
    } while (0)
  
  #define ctxt_push(object, stack) \
!   GSIArrayAddItem((GSIArray)stack, (GSIArrayItem)object)
  
  /* Globally unique gstate number */
  static unsigned int unique_index = 0;
--- 94,100 ----
    } while (0)
  
  #define ctxt_push(object, stack) \
!   GSIArrayAddItem((GSIArray)stack, (GSIArrayItem)((id)object))
  
  /* Globally unique gstate number */
  static unsigned int unique_index = 0;
Index: base/Source/GSAttributedString.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/GSAttributedString.m,v
retrieving revision 1.26
diff -c -r1.26 GSAttributedString.m
*** base/Source/GSAttributedString.m	22 May 2005 03:32:12 -0000	1.26
--- base/Source/GSAttributedString.m	7 Oct 2005 03:44:18 -0000
***************
*** 127,133 ****
    GSIMapNode	node;
  
    ALOCK();
!   node = GSIMapNodeForKey(&attrMap, (GSIMapKey)attrs);
    if (node == 0)
      {
        /*
--- 127,133 ----
    GSIMapNode	node;
  
    ALOCK();
!   node = GSIMapNodeForKey(&attrMap, (GSIMapKey)((id)attrs));
    if (node == 0)
      {
        /*
***************
*** 135,141 ****
         * in an immutable dictionary that can safely be cached.
         */
        attrs = [[NSDictionary alloc] initWithDictionary: attrs copyItems: NO];
!       GSIMapAddPair(&attrMap, (GSIMapKey)attrs, (GSIMapVal)(unsigned)1);
      }
    else
      {
--- 135,141 ----
         * in an immutable dictionary that can safely be cached.
         */
        attrs = [[NSDictionary alloc] initWithDictionary: attrs copyItems: NO];
!       GSIMapAddPair(&attrMap, (GSIMapKey)((id)attrs), (GSIMapVal)(unsigned)1);
      }
    else
      {
***************
*** 152,163 ****
    GSIMapBucket       bucket;
  
    ALOCK();
!   bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)attrs);
    if (bucket != 0)
      {
        GSIMapNode     node;
  
!       node = GSIMapNodeForKeyInBucket(&attrMap, bucket, (GSIMapKey)attrs);
        if (node != 0)
  	{
  	  if (--node->value.uint == 0)
--- 152,163 ----
    GSIMapBucket       bucket;
  
    ALOCK();
!   bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)((id)attrs));
    if (bucket != 0)
      {
        GSIMapNode     node;
  
!       node = GSIMapNodeForKeyInBucket(&attrMap, bucket, (GSIMapKey)((id)attrs));
        if (node != 0)
  	{
  	  if (--node->value.uint == 0)
Index: base/Source/NSConnection.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSConnection.m,v
retrieving revision 1.143
diff -c -r1.143 NSConnection.m
*** base/Source/NSConnection.m	8 Jul 2005 11:48:34 -0000	1.143
--- base/Source/NSConnection.m	7 Oct 2005 03:44:23 -0000
***************
*** 3077,3084 ****
    NSAssert(node == 0, NSInternalInconsistencyException);
  
    RETAIN(anObj);
!   GSIMapAddPair(_localObjects, (GSIMapKey)object, (GSIMapVal)anObj);
!   GSIMapAddPair(_localTargets, (GSIMapKey)target, (GSIMapVal)anObj);
  
    if (debug_connection > 2)
      NSLog(@"add local object (0x%x) target (0x%x) "
--- 3077,3084 ----
    NSAssert(node == 0, NSInternalInconsistencyException);
  
    RETAIN(anObj);
!   GSIMapAddPair(_localObjects, (GSIMapKey)object, (GSIMapVal)((id)anObj));
!   GSIMapAddPair(_localTargets, (GSIMapKey)target, (GSIMapVal)((id)anObj));
  
    if (debug_connection > 2)
      NSLog(@"add local object (0x%x) target (0x%x) "
***************
*** 3307,3313 ****
  		  GSIMapRemoveKey(_localTargets, (GSIMapKey)nTarget);
  		  ((ProxyStruct*)proxy)->_handle = target;
  		  GSIMapAddPair(_localTargets, (GSIMapKey)target,
! 		    (GSIMapVal)proxy);
  		}
  	      M_UNLOCK(c->_proxiesGate);
  	    }
--- 3307,3313 ----
  		  GSIMapRemoveKey(_localTargets, (GSIMapKey)nTarget);
  		  ((ProxyStruct*)proxy)->_handle = target;
  		  GSIMapAddPair(_localTargets, (GSIMapKey)target,
! 		    (GSIMapVal)((id)proxy));
  		}
  	      M_UNLOCK(c->_proxiesGate);
  	    }
***************
*** 3464,3470 ****
    if (p == nil && aProxy != nil)
      {
        p = aProxy;
!       GSIMapAddPair(_remoteProxies, (GSIMapKey)aTarget, (GSIMapVal)p);
      }
    /*
     * Whether this is a new proxy or an existing proxy, this method is
--- 3464,3470 ----
    if (p == nil && aProxy != nil)
      {
        p = aProxy;
!       GSIMapAddPair(_remoteProxies, (GSIMapKey)aTarget, (GSIMapVal)((id)p));
      }
    /*
     * Whether this is a new proxy or an existing proxy, this method is
Index: base/Source/NSKeyedUnarchiver.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSKeyedUnarchiver.m,v
retrieving revision 1.15
diff -c -r1.15 NSKeyedUnarchiver.m
*** base/Source/NSKeyedUnarchiver.m	22 May 2005 03:32:13 -0000	1.15
--- base/Source/NSKeyedUnarchiver.m	7 Oct 2005 03:44:24 -0000
***************
*** 765,771 ****
  	  count = [_objects count];
  	  GSIArrayInitWithZoneAndCapacity(_objMap, _zone, count);
  	  // Add marker for nil object
! 	  GSIArrayAddItem(_objMap, (GSIArrayItem)[NSNull null]);
  	  // Add markers for unencoded objects.
  	  for (i = 1; i < count; i++)
  	    {
--- 765,771 ----
  	  count = [_objects count];
  	  GSIArrayInitWithZoneAndCapacity(_objMap, _zone, count);
  	  // Add marker for nil object
! 	  GSIArrayAddItem(_objMap, (GSIArrayItem)((id)[NSNull null]));
  	  // Add markers for unencoded objects.
  	  for (i = 1; i < count; i++)
  	    {
Index: base/Source/NSNotificationCenter.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSNotificationCenter.m,v
retrieving revision 1.51
diff -c -r1.51 NSNotificationCenter.m
*** base/Source/NSNotificationCenter.m	22 May 2005 03:32:13 -0000	1.51
--- base/Source/NSNotificationCenter.m	7 Oct 2005 03:44:26 -0000
***************
*** 697,703 ****
        /*
         * Locate the map table for this name - create it if not present.
         */
!       n = GSIMapNodeForKey(NAMED, (GSIMapKey)name);
        if (n == 0)
  	{
  	  m = mapNew(TABLE);
--- 697,703 ----
        /*
         * Locate the map table for this name - create it if not present.
         */
!       n = GSIMapNodeForKey(NAMED, (GSIMapKey)(id)name);
        if (n == 0)
  	{
  	  m = mapNew(TABLE);
***************
*** 706,712 ****
  	   * copy of the name so it cannot be mutated while in the map.
  	   */
  	  name = [name copyWithZone: NSDefaultMallocZone()];
! 	  GSIMapAddPair(NAMED, (GSIMapKey)name, (GSIMapVal)(void*)m);
  	}
        else
  	{
--- 706,712 ----
  	   * copy of the name so it cannot be mutated while in the map.
  	   */
  	  name = [name copyWithZone: NSDefaultMallocZone()];
! 	  GSIMapAddPair(NAMED, (GSIMapKey)(id)name, (GSIMapVal)(void*)m);
  	}
        else
  	{
***************
*** 842,848 ****
  	  if (m->nodeCount == 0)
  	    {
  	      mapFree(TABLE, m);
! 	      GSIMapRemoveKey(NAMED, (GSIMapKey)thisName);
  	    }
  	}
  
--- 842,848 ----
  	  if (m->nodeCount == 0)
  	    {
  	      mapFree(TABLE, m);
! 	      GSIMapRemoveKey(NAMED, (GSIMapKey)(id)thisName);
  	    }
  	}
  
***************
*** 879,885 ****
        /*
         * Locate the map table for this name.
         */
!       n0 = GSIMapNodeForKey(NAMED, (GSIMapKey)name);
        if (n0 == 0)
  	{
  	  unlockNCTable(TABLE);
--- 879,885 ----
        /*
         * Locate the map table for this name.
         */
!       n0 = GSIMapNodeForKey(NAMED, (GSIMapKey)((id)name));
        if (n0 == 0)
  	{
  	  unlockNCTable(TABLE);
***************
*** 911,917 ****
        if (m->nodeCount == 0)
  	{
  	  mapFree(TABLE, m);
! 	  GSIMapRemoveKey(NAMED, (GSIMapKey)name);
  	}
      }
    unlockNCTable(TABLE);
--- 911,917 ----
        if (m->nodeCount == 0)
  	{
  	  mapFree(TABLE, m);
! 	  GSIMapRemoveKey(NAMED, (GSIMapKey)((id)name));
  	}
      }
    unlockNCTable(TABLE);
***************
*** 1000,1006 ****
     */
    if (name)
      {
!       n = GSIMapNodeForKey(NAMED, (GSIMapKey)name);
        if (n)
  	{
  	  m = (GSIMapTable)n->value.ptr;
--- 1000,1006 ----
     */
    if (name)
      {
!       n = GSIMapNodeForKey(NAMED, (GSIMapKey)((id)name));
        if (n)
  	{
  	  m = (GSIMapTable)n->value.ptr;
Index: base/Source/NSPortCoder.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSPortCoder.m,v
retrieving revision 1.50
diff -c -r1.50 NSPortCoder.m
*** base/Source/NSPortCoder.m	18 Jul 2005 10:12:49 -0000	1.50
--- base/Source/NSPortCoder.m	7 Oct 2005 03:44:28 -0000
***************
*** 695,701 ****
  		    GSNameFromClass([self class]), GSNameFromSelector(_cmd));
  		}
  	      classInfo = [GSClassInfo newWithClass: c andVersion: cver];
! 	      GSIArrayAddItem(_clsAry, (GSIArrayItem)classInfo);
  	      *(Class*)address = classInfo->class;
  	      /*
  	       *	Point the address to a dummy location and read the
--- 695,701 ----
  		    GSNameFromClass([self class]), GSNameFromSelector(_cmd));
  		}
  	      classInfo = [GSClassInfo newWithClass: c andVersion: cver];
! 	      GSIArrayAddItem(_clsAry, (GSIArrayItem)((id)classInfo));
  	      *(Class*)address = classInfo->class;
  	      /*
  	       *	Point the address to a dummy location and read the
Index: base/Source/NSRunLoop.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSRunLoop.m,v
retrieving revision 1.121
diff -c -r1.121 NSRunLoop.m
*** base/Source/NSRunLoop.m	22 May 2005 03:32:14 -0000	1.121
--- base/Source/NSRunLoop.m	7 Oct 2005 03:44:30 -0000
***************
*** 412,418 ****
      {
        item->_date = RETAIN(theFuture);
      }
!   GSIArrayInsertSorted(watchers, (GSIArrayItem)item, aSort);
  }
  
  - (void) _checkPerformers: (GSRunLoopCtxt*)context
--- 412,418 ----
      {
        item->_date = RETAIN(theFuture);
      }
!   GSIArrayInsertSorted(watchers, (GSIArrayItem)((id)item), aSort);
  }
  
  - (void) _checkPerformers: (GSRunLoopCtxt*)context
***************
*** 763,769 ****
        RELEASE(context);
      }
    timers = context->timers;
!   GSIArrayInsertSorted(timers, (GSIArrayItem)timer, aSort);
  }
  
  
--- 763,769 ----
        RELEASE(context);
      }
    timers = context->timers;
!   GSIArrayInsertSorted(timers, (GSIArrayItem)((id)timer), aSort);
  }
  
  
***************
*** 816,822 ****
  	      if (timerInvalidated(min_timer) == NO)
  		{
  		  GSIArrayInsertSortedNoRetain(timers,
! 		    (GSIArrayItem)min_timer, aSort);
  		}
  	      else
  		{
--- 816,822 ----
  	      if (timerInvalidated(min_timer) == NO)
  		{
  		  GSIArrayInsertSortedNoRetain(timers,
! 		    (GSIArrayItem)((id)min_timer), aSort);
  		}
  	      else
  		{
***************
*** 880,886 ****
  		       */
  		      ASSIGN(min_watcher->_date, nxt);
  		      GSIArrayInsertSortedNoRetain(watchers,
! 			(GSIArrayItem)min_watcher, aSort);
  		    }
  		  else
  		    {
--- 880,886 ----
  		       */
  		      ASSIGN(min_watcher->_date, nxt);
  		      GSIArrayInsertSortedNoRetain(watchers,
! 			(GSIArrayItem)((id)min_watcher), aSort);
  		    }
  		  else
  		    {
***************
*** 1326,1338 ****
  	      p = GSIArrayItemAtIndex(performers, i).obj;
  	      if (p->order > order)
  		{
! 		  GSIArrayInsertItem(performers, (GSIArrayItem)item, i);
  		  break;
  		}
  	    }
  	  if (i == end)
  	    {
! 	      GSIArrayInsertItem(performers, (GSIArrayItem)item, i);
  	    }
  	}
        RELEASE(item);
--- 1326,1338 ----
  	      p = GSIArrayItemAtIndex(performers, i).obj;
  	      if (p->order > order)
  		{
! 		  GSIArrayInsertItem(performers, (GSIArrayItem)((id)item), i);
  		  break;
  		}
  	    }
  	  if (i == end)
  	    {
! 	      GSIArrayInsertItem(performers, (GSIArrayItem)((id)item), i);
  	    }
  	}
        RELEASE(item);
Index: base/Source/NSSerializer.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSSerializer.m,v
retrieving revision 1.64
diff -c -r1.64 NSSerializer.m
*** base/Source/NSSerializer.m	8 Jul 2005 11:48:35 -0000	1.64
--- base/Source/NSSerializer.m	7 Oct 2005 03:44:32 -0000
***************
*** 592,598 ****
  	   */
  	  if (info->didUnique)
  	    {
! 	      GSIArrayAddItem(&info->array, (GSIArrayItem)s);
  	    }
  	  return s;
  	}
--- 592,598 ----
  	   */
  	  if (info->didUnique)
  	    {
! 	      GSIArrayAddItem(&info->array, (GSIArrayItem)((id)s));
  	    }
  	  return s;
  	}
***************
*** 650,656 ****
  	   */
  	  if (info->didUnique)
  	    {
! 	      GSIArrayAddItem(&info->array, (GSIArrayItem)s);
  	    }
  	  return s;
  	}
--- 650,656 ----
  	   */
  	  if (info->didUnique)
  	    {
! 	      GSIArrayAddItem(&info->array, (GSIArrayItem)((id)s));
  	    }
  	  return s;
  	}
Index: base/Source/NSUnarchiver.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSUnarchiver.m,v
retrieving revision 1.66
diff -c -r1.66 NSUnarchiver.m
*** base/Source/NSUnarchiver.m	18 Jul 2005 10:12:49 -0000	1.66
--- base/Source/NSUnarchiver.m	7 Oct 2005 03:44:34 -0000
***************
*** 757,763 ****
  		}
  	      RELEASE(className);
  	      classInfo->version = cver;
! 	      GSIArrayAddItem(clsMap, (GSIArrayItem)classInfo);
  	      *(Class*)address = mapClassObject(classInfo);
  	      /*
  	       *	Point the address to a dummy location and read the
--- 757,763 ----
  		}
  	      RELEASE(className);
  	      classInfo->version = cver;
! 	      GSIArrayAddItem(clsMap, (GSIArrayItem)((id)classInfo));
  	      *(Class*)address = mapClassObject(classInfo);
  	      /*
  	       *	Point the address to a dummy location and read the
Index: gui/Source/GSTextStorage.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/GSTextStorage.m,v
retrieving revision 1.43
diff -c -r1.43 GSTextStorage.m
*** gui/Source/GSTextStorage.m	26 May 2005 02:52:43 -0000	1.43
--- gui/Source/GSTextStorage.m	7 Oct 2005 03:44:38 -0000
***************
*** 86,92 ****
    GSIMapNode	node;
  
    ALOCK();
!   node = GSIMapNodeForKey(&attrMap, (GSIMapKey)attrs);
    if (node == 0)
      {
        /*
--- 86,92 ----
    GSIMapNode	node;
  
    ALOCK();
!   node = GSIMapNodeForKey(&attrMap, (GSIMapKey)((id)attrs));
    if (node == 0)
      {
        /*
***************
*** 94,100 ****
         * in an immutable dictionary that can safely be cached.
         */
        attrs = [[NSDictionary alloc] initWithDictionary: attrs copyItems: NO];
!       GSIMapAddPair(&attrMap, (GSIMapKey)attrs, (GSIMapVal)(unsigned)1);
      }
    else
      {
--- 94,100 ----
         * in an immutable dictionary that can safely be cached.
         */
        attrs = [[NSDictionary alloc] initWithDictionary: attrs copyItems: NO];
!       GSIMapAddPair(&attrMap, (GSIMapKey)((id)attrs), (GSIMapVal)(unsigned)1);
      }
    else
      {
***************
*** 111,122 ****
    GSIMapBucket       bucket;
  
    ALOCK();
!   bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)attrs);
    if (bucket != 0)
      {
        GSIMapNode     node;
  
!       node = GSIMapNodeForKeyInBucket(&attrMap, bucket, (GSIMapKey)attrs);
        if (node != 0)
  	{
  	  if (--node->value.uint == 0)
--- 111,122 ----
    GSIMapBucket       bucket;
  
    ALOCK();
!   bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)((id)attrs));
    if (bucket != 0)
      {
        GSIMapNode     node;
  
!       node = GSIMapNodeForKeyInBucket(&attrMap, bucket, (GSIMapKey)((id)attrs));
        if (node != 0)
  	{
  	  if (--node->value.uint == 0)
Index: gui/Source/NSView.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSView.m,v
retrieving revision 1.237
diff -c -r1.237 NSView.m
*** gui/Source/NSView.m	25 Aug 2005 07:44:25 -0000	1.237
--- gui/Source/NSView.m	7 Oct 2005 03:44:45 -0000
***************
*** 3065,3071 ****
    /*
     * Set up 'previous' link in aView to point to us.
     */
!   GSIArraySetItemAtIndex(pKV(aView), (GSIArrayItem)self, 0);
  
    /*
     * Tell our current 'next' view that we are no longer pointing to it.
--- 3065,3071 ----
    /*
     * Set up 'previous' link in aView to point to us.
     */
!   GSIArraySetItemAtIndex(pKV(aView), (GSIArrayItem)((id)self), 0);
  
    /*
     * Tell our current 'next' view that we are no longer pointing to it.
***************
*** 3094,3100 ****
    /*
     * Set up 'next' link to point to aView.
     */
!   GSIArraySetItemAtIndex(nKV(self), (GSIArrayItem)aView, 0);
  }
  
  /**
--- 3094,3100 ----
    /*
     * Set up 'next' link to point to aView.
     */
!   GSIArraySetItemAtIndex(nKV(self), (GSIArrayItem)((id)aView), 0);
  }
  
  /**
#include <stdio.h>

typedef union {
  int x;
  void *y;
} test_union;

void foo(test_union a)
{
  puts("here");
}

int main(char *argv[], int argc)
{
  long a = 1024; // somevalue...
  foo((test_union)a);

  puts("hello");
  return 0;
}
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to