diff mbox

No allocation for empty unordered containers

Message ID 20140909172900.GE22778@redhat.com
State New
Headers show

Commit Message

Jonathan Wakely Sept. 9, 2014, 5:29 p.m. UTC
On 14/08/14 21:22 +0200, François Dumont wrote:
>I am preparing a patch for profile mode so I will submit modification 
>for this mode with this big patch.

btw, François, for profile mode I think we should just do something
like this patch.

I feel quite strongly that if using Debug Mode or Profile Mode makes
your program run out of memory where it wouldn't usually fail, then
terminating is reasonable. The point of Profile Mode is not to test
abnormal execution of your program because that won't give you useful
profile information for the normal case.

It's more important for the noexcept specification to be consistent
across normal/debug/profile modes than for profile mode to fail
gracefully via bad_alloc in out-of-memory scenarios.

Comments

François Dumont Sept. 9, 2014, 9:03 p.m. UTC | #1
On 09/09/2014 19:29, Jonathan Wakely wrote:
> On 14/08/14 21:22 +0200, François Dumont wrote:
>> I am preparing a patch for profile mode so I will submit modification 
>> for this mode with this big patch.
>
> btw, François, for profile mode I think we should just do something
> like this patch.
>
> I feel quite strongly that if using Debug Mode or Profile Mode makes
> your program run out of memory where it wouldn't usually fail, then
> terminating is reasonable. The point of Profile Mode is not to test
> abnormal execution of your program because that won't give you useful
> profile information for the normal case.
>
> It's more important for the noexcept specification to be consistent
> across normal/debug/profile modes than for profile mode to fail
> gracefully via bad_alloc in out-of-memory scenarios.
>
     Sure, no problem. In the patch I am preparing for profile mode 
failure in allocation will just mean that the involved container won't 
be profiled so that I can add noexcept wherever it is needed for 
consistency with normal mode. I hope to be able to submit this patch in 
a week or two.

François
Jonathan Wakely Sept. 9, 2014, 9:31 p.m. UTC | #2
On 09/09/14 23:03 +0200, François Dumont wrote:
>On 09/09/2014 19:29, Jonathan Wakely wrote:
>>On 14/08/14 21:22 +0200, François Dumont wrote:
>>>I am preparing a patch for profile mode so I will submit 
>>>modification for this mode with this big patch.
>>
>>btw, François, for profile mode I think we should just do something
>>like this patch.
>>
>>I feel quite strongly that if using Debug Mode or Profile Mode makes
>>your program run out of memory where it wouldn't usually fail, then
>>terminating is reasonable. The point of Profile Mode is not to test
>>abnormal execution of your program because that won't give you useful
>>profile information for the normal case.
>>
>>It's more important for the noexcept specification to be consistent
>>across normal/debug/profile modes than for profile mode to fail
>>gracefully via bad_alloc in out-of-memory scenarios.
>>
>    Sure, no problem. In the patch I am preparing for profile mode 
>failure in allocation will just mean that the involved container won't 
>be profiled so that I can add noexcept wherever it is needed for 
>consistency with normal mode. I hope to be able to submit this patch 
>in a week or two.

Great - thanks for working on it.
diff mbox

Patch

diff --git a/libstdc++-v3/include/profile/unordered_base.h b/libstdc++-v3/include/profile/unordered_base.h
index 283f87c..cd9db7e 100644
--- a/libstdc++-v3/include/profile/unordered_base.h
+++ b/libstdc++-v3/include/profile/unordered_base.h
@@ -154,7 +154,7 @@  namespace __profile
       using __unique_keys = std::integral_constant<bool, _Unique_keys>;
 
     protected:
-      _Unordered_profile()
+      _Unordered_profile() noexcept
       {
 	auto& __uc = _M_conjure();
 	__profcxx_hashtable_construct(&__uc, __uc.bucket_count());
@@ -162,10 +162,10 @@  namespace __profile
       }
       _Unordered_profile(const _Unordered_profile&)
 	: _Unordered_profile() { }
-      _Unordered_profile(_Unordered_profile&&)
+      _Unordered_profile(_Unordered_profile&&) noexcept
 	: _Unordered_profile() { }
 
-      ~_Unordered_profile() noexcept
+      ~_Unordered_profile()
       {
 	auto& __uc = _M_conjure();
 	__profcxx_hashtable_destruct(&__uc, __uc.bucket_count(), __uc.size());