This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++ versus -Wcast-align


On Tue, 6 May 2003, Benjamin Kosnik wrote:
>> The following hack really seems to work. and removes all warnings I got
>> for -Wcast-qual on sparc-sun-solaris2.9.  If I brush this up with a proper
>> ChangeLog and full testruns, would something like this be acceptable?
> Looks correct to me, and yes, it would be acceptable for both gcc-3.4
> (now) and gcc-3_3-branch when it opens.

Thanks for the quick response, and sorry for taking so long for the final
version, which was due to my real job and the fact that I didn't have a
proper testing environment under sparc-sun-solaris2.9 available.

I now tested the patch with bootstrap (C, C++) and testsuite runs with and
without this change on sparc-sun-solaris2.9 and committed the following to
the 3.3 branch.  After another round of testing I'll commit to mainline.

> Thanks for figuring this out!

Well, your initial feedback helped a lot! :-)

Gerald


2003-05-21  Gerald Pfeifer  <pfeifer@dbai.tuwien.ac.at>

	* include/bits/stl_alloc.h (__default_alloc_template::_S_chunk_alloc):
	Cast via void* to avoid -Wcast-align warnings.
	(__default_alloc_template::_S_refill): Likewise.

Index: include//bits/stl_alloc.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_alloc.h,v
retrieving revision 1.26.2.4
diff -u -3 -p -r1.26.2.4 stl_alloc.h
--- include//bits/stl_alloc.h	28 Feb 2003 02:28:13 -0000	1.26.2.4
+++ include//bits/stl_alloc.h	20 May 2003 22:15:44 -0000
@@ -500,8 +500,8 @@ namespace std
               _Obj* volatile* __my_free_list =
                 _S_free_list + _S_freelist_index(__bytes_left);

-              ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
-              *__my_free_list = (_Obj*)_S_start_free;
+              ((_Obj*)(void*)_S_start_free) -> _M_free_list_link = *__my_free_list;
+              *__my_free_list = (_Obj*)(void*)_S_start_free;
             }
           _S_start_free = (char*) __new_alloc::allocate(__bytes_to_get);
           if (_S_start_free == 0)
@@ -559,12 +559,12 @@ namespace std
       __my_free_list = _S_free_list + _S_freelist_index(__n);

       // Build free list in chunk.
-      __result = (_Obj*)__chunk;
-      *__my_free_list = __next_obj = (_Obj*)(__chunk + __n);
+      __result = (_Obj*)(void*)__chunk;
+      *__my_free_list = __next_obj = (_Obj*)(void*)(__chunk + __n);
       for (__i = 1; ; __i++)
         {
 	  __current_obj = __next_obj;
-          __next_obj = (_Obj*)((char*)__next_obj + __n);
+          __next_obj = (_Obj*)(void*)((char*)__next_obj + __n);
 	  if (__nobjs - 1 == __i)
 	    {
 	      __current_obj -> _M_free_list_link = 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]