This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


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

Re: PATCH:stl/stl_alloc.h triggers compiler warnings


>>>>> 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

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