PATCH (libstdc++-v3): obscure portability issue

Loren James Rittle rittle@latour.waar.labs.mot.com
Wed Jan 19 21:57:00 GMT 2005


(Ah, compiler bugs being fixed makes life happy...  Thank you wanderer
for naming Jakub as our savior.  I had stopped working on platform
library issues.  Sorry I didn't catch this Benjamin; it kills 8 more FAILs.)

This strange macro exists on various versions of FreeBSD (and perhaps
other strains of BSD):

/usr/include/sys/cdefs.h:#define __used         __attribute__((__used__))

Therefore, avoid use therein (as regression checked and will be
applied to mainline ASAP):

	* include/ext/array_allocator.h (array_allocator<>::allocate):
	Avoid __used.  Use __array_used instead.

Index: libstdc++-v3/include/ext/array_allocator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/array_allocator.h,v
retrieving revision 1.7
diff -c -r1.7 array_allocator.h
*** libstdc++-v3/include/ext/array_allocator.h	24 Nov 2004 04:11:11 -0000	1.7
--- libstdc++-v3/include/ext/array_allocator.h	19 Jan 2005 21:41:59 -0000
***************
*** 1,6 ****
  // array allocator -*- C++ -*-
  
! // Copyright (C) 2004 Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
--- 1,6 ----
  // array allocator -*- C++ -*-
  
! // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
***************
*** 120,130 ****
        pointer
        allocate(size_type __n, const void* = 0)
        {
! 	static size_type __used;
! 	if (_M_array == 0 || __used + __n > _M_array->size())
  	  std::__throw_bad_alloc();
! 	pointer __ret = _M_array->begin() + __used;
! 	__used += __n;
  	return __ret;
        }
      };
--- 120,130 ----
        pointer
        allocate(size_type __n, const void* = 0)
        {
! 	static size_type __array_used;
! 	if (_M_array == 0 || __array_used + __n > _M_array->size())
  	  std::__throw_bad_alloc();
! 	pointer __ret = _M_array->begin() + __array_used;
! 	__array_used += __n;
  	return __ret;
        }
      };



More information about the Libstdc++ mailing list