[libstdc++] Assertion in optional

Marc Glisse marc.glisse@inria.fr
Sun May 14 07:20:00 GMT 2017


Hello,

this patch adds 2 simple __glibcxx_assert in optional that match the 
precondition in the comment above. I am not sure if there was a reason the 
author wrote that comment instead of the assertion, but constexpr use 
still seems to work.

I hesitated about having the assertion in operator*, etc, so that the 
error message would be clearer, but we would still be missing the key 
information of where this function was called from (in user code), so the 
real solution would be for __glibcxx_assert to print (a few lines of) a 
stack trace, an unrelated issue.

Bootstrap+testsuite on powerpc64le-unknown-linux-gnu.

2017-05-15  Marc Glisse  <marc.glisse@inria.fr>

 	* include/std/optional (_Optional_base::_M_get): Check precondition.
 	* testsuite/20_util/optional/cons/value_neg.cc: Update line numbers.

-- 
Marc Glisse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opt.diff
Type: text/x-diff
Size: 2469 bytes
Desc: 
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170514/46540640/attachment.bin>


More information about the Libstdc++ mailing list