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


> attached is a patch to stl/stl_alloc.h, to stop it triggering egcs compiler
> warnings when -Wcast-align has been given to the compiler. If you compile with
> -Wcast-align, to catch potential problems in your own code, it is rather
> disturbing that each instantiation of an allocator produces several!

Unfortunately, this was not enough info for me to reproduce your problem.
Can you please send a self-enclosed sample, and give compiler and host
info?

> 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? Does the 3.2 SGI release still have this problem?

Anyway.

-Benjamin



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