Subject: Re: [boost] [Boost.Pool] TR1?
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-04-14 14:16:27
On 13 Apr 2011, at 23:26, Dave Abrahams wrote:
> At Wed, 13 Apr 2011 14:17:15 -0700,
> Phil Bouchard wrote:
>>> To make is_from work, we need a total, *specified* ordering for all
>>> pointers. I see no way to combine the above two to get a total specified
>> There is s bug in the standards because according to 5.2.10/4 a
>> pointer can be converted to an integral type to later be ordered.
>> struct Silly
>> bool is_from(const char* p)
>> return !std::less<long>()(reinterpret_cast<long>(p),
>> reinterpret_cast<long>(buffer)) &&
>> reinterpret_cast<long>(buffer + sizeof(buffer)));
>> char buffer;
> Stop, stop, seriously. That's not a bug, and your code isn't
> guaranteed to produce any particular result either, portably.
> reinterpret_cast has unspecified or implementation-defined results (I
> forget which) in this case.
> If you don't believe me, take the question to some "higher authority"
> on the C++ core standard, such as you might find on comp.std.c++, but
> please stop wasting time arguing with me about it in this forum.
> I fear my whole point was missed: since there's no way to implement
> is_from in portable standard-compliant user code, it makes sense that
> (if it's actually broadly needed) it should go in the standard as you
> suggested, and as a first step, it should go in Boost.
There are other places in Boost which make use of undefined behaviour. Further, lots of bits of boost are compiler-specific, and many compilers guarantee that is_from with < will work fine.
In every standard library I have ever seen, std::less for pointers is just defined using <. Further, < works on all pointers, because all C++ compilers I'm aware of allow code which works on raw memory, without malloc/new.
Unless anyone produces a compiler which compiles even a tiny part of Boost and miscompiles any of this code, I would just leave it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk