[PATCH] D40834: [libc++] std::map: use throw_out_of_range()
Petteri Aimonen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 5 05:53:26 PST 2017
PetteriAimonen created this revision.
Herald added a reviewer: EricWF.
Previously std::map ignored out-of-bounds access when exceptions were
disabled. Other containers such as std::vector use throw_out_of_range()
which will terminate the program if exceptions are disabled.
https://reviews.llvm.org/D40834
Files:
include/map
Index: include/map
===================================================================
--- include/map
+++ include/map
@@ -1371,10 +1371,8 @@
{
__parent_pointer __parent;
__node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr)
- throw out_of_range("map::at: key not found");
-#endif // _LIBCPP_NO_EXCEPTIONS
+ _VSTD::__throw_out_of_range("map::at: key not found");
return static_cast<__node_pointer>(__child)->__value_.__cc.second;
}
@@ -1384,10 +1382,8 @@
{
__parent_pointer __parent;
__node_base_pointer __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr)
- throw out_of_range("map::at: key not found");
-#endif // _LIBCPP_NO_EXCEPTIONS
+ _VSTD::__throw_out_of_range("map::at: key not found");
return static_cast<__node_pointer>(__child)->__value_.__cc.second;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40834.125506.patch
Type: text/x-patch
Size: 964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171205/e5f1b485/attachment-0001.bin>
More information about the cfe-commits
mailing list