Issue 2143: Chromium allocators prevent building in VC++2008 SP1
http://code.google.com/p/chromium/issues/detail?id=2143
New issue report by drpizza:
A few minor issues preclude successful release mode building in VC++ 2008
SP1.
The requirements for C++ allocators are listed in section 20.1.5 of the
standard. In particular,
there is a requirement that for an allocator A of type X<T>, it is possible
to construct an allocator
B of type X<U> thus: X<U> b(a);
That is to say, allocators must have a templated copy constructor allowing
the value_type to vary.
VC++2005 does not (seem to) do anything to enforce this requirement. Nor
does VC++2008 in a debug
build. However, in a release build, the library attempts to use the
constructor in question, and duly
fails to find it.
The specific allocators with this issue are:
StackAllocator from base\stack_container.h
PrivateHookAllocator from tools\memory_watcher\memory_hook.h
The fix in the latter case is simple; simply add the constructor. The
PrivateHookAllocator is
stateless, so the constructor does nothing, it merely allows suitable
objects to be constructed.
The fix in the former case is more complex. StackAllocator is stateful; it
contains a pointer to a
Source object that contains the actual buffer. When constructing a
StackAllocator<U> from a
StackAllocator<T>, we cannot use the Source from the StackAllocator<T>, as
it only contains enough
space for a given number of Ts; that is feasibly not enough even for a
single U.
My solution is to allow the Source to be null, and in such situations
revert to using the normal
std::allocator to allocate memory. The StackAllocator already uses
std::allocator when its memory is
full, so I think this should be a safe thing to do, although it does mean
sacrificing the performance
advantage of the stack allocation in such situations.
One possible refinement might be to share the Source if sizeof(T) <=
sizeof(U). However, it is not
obvious to me that this is worthwhile, not least because of the ugly cast
that would be required.
Issue attributes:
Status: Unconfirmed
Owner: [EMAIL PROTECTED]
Labels: Type-Bug Pri-2 OS-All Area-Unknown
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Chromium-bugs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/chromium-bugs?hl=en
-~----------~----~----~----~------~----~------~--~---