Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #3623

Re: To standardize Boost.Pool

Date 2011-04-13 15:57 -0700
From Phil Bouchard <phil@fornux.com>
Newsgroups comp.lang.c++
Subject Re: To standardize Boost.Pool
References (2 earlier) <4da4eede@news.x-privat.org> <4da54bdd$1@news.x-privat.org> <5497ee99-8d91-4412-8995-6e1ea58ded81@32g2000vbe.googlegroups.com> <4da5d23b@news.x-privat.org> <4da61a7b$1@news.x-privat.org>
Message-ID <4da62a76@news.x-privat.org> (permalink)
Organization X-Privat.Org NNTP Server - http://www.x-privat.org

Show all headers | View raw


On 4/13/2011 2:49 PM, Phil Bouchard wrote:
>
> There was a discussion on the validity of a 'false' statement returned
> by is_from() because out-of-bounds pointer comparison would invoke
> undefined behavior according to 5.7.6. This was bringing the idea of
> having adjacent pools stack & data to the heap pool.
>
> But it looks like heap.is_from() could work without adjacent stack and
> data pools in all cases, even if the pointers are arbitrary. This is
> because they can be casted to an integral type before they are compared
> together as stated by 5.2.10/4. The following example is thus valid for
> arbitrary pointers:
>
> bool is_from(const char* p)
> {
> return reinterpret_cast<long>(buffer)<= reinterpret_cast<long>(p)&&
> reinterpret_cast<long>(p)< reinterpret_cast<long>(buffer + sizeof(buffer));
> }

Sorry, it's actually "implementation defined" but perhaps a 
reinterpret_cast of a pointer to a long integer could be guaranteed to 
be valid by the standards, long being the greatest integer available on 
a system.


-Phil

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

To standardize Boost.Pool  Phil Bouchard <phil@fornux.com> - 2011-04-12 07:44 -0600
  Re: To standardize Boost.Pool Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-04-12 21:56 +0000
    Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-12 17:31 -0700
      Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 00:08 -0700
        Re: To standardize Boost.Pool Öö Tiib <ootiib@hot.ee> - 2011-04-13 08:28 -0700
          Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 09:41 -0700
            Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 14:49 -0700
              Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 15:57 -0700
                Re: To standardize Boost.Pool Paavo Helde <myfirstname@osa.pri.ee> - 2011-04-13 23:39 -0500
                Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 22:43 -0700
                Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 22:53 -0700
                Re: To standardize Boost.Pool Miles Bader <miles@gnu.org> - 2011-04-14 15:55 +0900
                Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-14 00:15 -0700

csiph-web