Discussion:
About monotonic_buffer_resource::do_allocate
(too old to reply)
FrankHB1989
2018-11-25 21:32:04 UTC
Permalink
What will happen when the size `bytes` is too large, say, size_t(-1), in
calling `monotonic_buffer_resource::do_allocate`?

There has to be room for the administrative data along with the request
space, so the resulted allocation request for upstream allocator (with size
`n`) is effectively more than `bytes` (also suggested by
[mem.res.monotonic.buffer.mem]/5
<http://eel.is/c++draft/mem.res.monotonic.buffer.mem#5>). As a result, it
seems the allocation can't succeed. However, as per
[mem.res.monotonic.buffer.mem]/6
<http://eel.is/c++draft/mem.res.monotonic.buffer.mem#6>, it is also not
allowed to throw unless the upstream resource allocation is throwing, which
makes it impossible to throw in this case because the failure occurs before
the allocation call to the upstream resource. So what should a conforming
implementation do?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Alberto Barbati
2018-11-26 09:57:32 UTC
Permalink
I guess a Requires: (or, better, Expects:) clause would be useful here, to
address this corner case while not imposing a burden to
monotonic_buffer_resource.
Post by FrankHB1989
What will happen when the size `bytes` is too large, say, size_t(-1), in
calling `monotonic_buffer_resource::do_allocate`?
There has to be room for the administrative data along with the request
space, so the resulted allocation request for upstream allocator (with size
`n`) is effectively more than `bytes` (also suggested by
[mem.res.monotonic.buffer.mem]/5
<http://eel.is/c++draft/mem.res.monotonic.buffer.mem#5>). As a result, it
seems the allocation can't succeed. However, as per
[mem.res.monotonic.buffer.mem]/6
<http://eel.is/c++draft/mem.res.monotonic.buffer.mem#6>, it is also not
allowed to throw unless the upstream resource allocation is throwing, which
makes it impossible to throw in this case because the failure occurs before
the allocation call to the upstream resource. So what should a conforming
implementation do?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
FrankHB1989
2018-11-29 04:37:48 UTC
Permalink
I see that MSVC 15.8.2 actually implements it with a throwing call (
_Xbad_alloc) in this case. So the problem seems already realistic. Is there
a DR covering it? Or someone to forward it as an LWG issue?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...