This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: PATCH:stl/stl_alloc.h triggers compiler warnings
- To: Benjamin Kosnik <bkoz@cygnus.com>
- Subject: Re: PATCH:stl/stl_alloc.h triggers compiler warnings
- From: Jason Merrill <jason@cygnus.com>
- Date: 28 Apr 1999 20:55:05 -0700
- Cc: nathan@cs.bris.ac.uk, libstdc++@sourceware.cygnus.com
- References: <Pine.LNX.3.96.990428192058.11848A-100000@happy.cygnus.com>
>>>>> Benjamin Kosnik <bkoz@cygnus.com> writes:
>> The default allocator contains code of the form ((T *)ptr), where ptr
>> is a char *. A T might be more strictly aligned, and so the compiler
>> warns. However, a correctly working allocator will not cause a problem
>> here (and the default allocator better be correct!), so it'd be nice to
>> tell the compiler we know what's going on. The way to do that is via a
>> void *, as in ((T *)(void *)ptr).
> Ugh. This seems like a terrible kludge, a cast to a cast to a value. Do
> you think that code would be cleaner if there was a char* conversion
> function in _Obj?
Noooooo! Conversion ops are almost always a bad idea; they make code
harder to read and usually have unforseen consequences. The double cast
seems much cleaner to me.
Jason