1 Mar 2000 08:16
Re: Bug in smart_ptr.hpp
Andreas Scherer <as <at> mitgmbh.de>
2000-03-01 07:16:28 GMT
2000-03-01 07:16:28 GMT
beman dawes <bema- <at> esva.net> wrote: > > So it really isn't something we can fix by changes in our files by > picking one of the native formats and converting everything to that > format. The problem is not that <smart_ptr.hpp> (and possibly other files in the boost archive as well) is in one of the native formats (say Unix versus Win32); the problem in this particular case is that <smart_ptr.hpp> is in a _mixed_ file format. The last time I looked (must have been version 1.11), one line in a multiline macro definition had the "wrong" eof character(s), so the preprocessor of gcc hickups. Apart from multiline macros, gcc on Unix/Linux is perfectly happy with "native Win32" source files, just as, e.g., MSVC deals fine with "native Unix" source files. To conclude, let me vote together with all those other gcc hackers to clean up <smart_ptr.hpp> once and for all. Please. -- Andreas
I've only looked *quickly* at your alignment code, however I don't think
that it quite guarentees correct alignment - as I understand it your code
only guarantees alignment on a sizeof(char*) boundary, but there may be
types which require alignment on a larger boundary than that, I figured
that the logic goes like this:
1) we need to store two differnt types T and U in the same memory location
- so that memory must be properly aligned for both T and U - that is the
smallest number A which has both Align(T) and Align(U) as a factor.
2)The memory must be large enough for both T and U, and rounded up to a
multiple of A - the common alignment factor.
The code I put together only deels with (1) - finding the alignment
requirements of any type T, and combining to alignments into a "smallest
common multiple", the rest is somewhat easier (I hope!).
Anyway here is the code with a short test program, the classes alignment_of
and least_common_mult do all the work:
#include <iostream>
#include <set>
RSS Feed