Boost logo

Boost :

Subject: Re: [boost] [Boost.Pool] TR1?
From: Phil Bouchard (philippe_at_[hidden])
Date: 2011-04-12 19:06:19


On 4/12/2011 3:41 PM, Nevin Liber wrote:
>
> To illustrate this, take the following code:
>
> struct Silly
> {
> bool is_from(const char* p)
> { return buffer<= p&& p< buffer + sizeof(buffer); }
>
> char buffer[1024];
> };
>
> I believe that a compiler could legally optimize the body of Silly::is_from
> to be:
> { return true; }
>
> because in the defined behavior case it returns true, and the compiler can
> do whatever it wants in the undefined behavior case.

Is that so? I guess it'll be different if you have:

struct Silly
{
      bool is_from_heap(const char* p)
      { return heap<= p&& p< heap + sizeof(heap); }

      char data[1024];
      char heap[1024];
      char stack[1024];
};

> As Dave pointed out, the Boost-related issue is that Bool.Pool has a
> function relying on underfined behavior...

-Phil


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk