You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

472 lines
20KB

  1. // Debugging support implementation -*- C++ -*-
  2. // Copyright (C) 2003-2020 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file debug/macros.h
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_MACROS_H
  24. #define _GLIBCXX_DEBUG_MACROS_H 1
  25. /**
  26. * Macros used by the implementation to verify certain
  27. * properties. These macros may only be used directly by the debug
  28. * wrappers. Note that these are macros (instead of the more obviously
  29. * @a correct choice of making them functions) because we need line and
  30. * file information at the call site, to minimize the distance between
  31. * the user error and where the error is reported.
  32. *
  33. */
  34. #if 0 /* defined _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED */
  35. # define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \
  36. if (__builtin_is_constant_evaluated()) \
  37. /* FIXME: Compilation error here when !_Cond. */ \
  38. break; \
  39. if (! (_Cond)) \
  40. __gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
  41. ._ErrMsg._M_error()
  42. #else
  43. # define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \
  44. if (! (_Cond)) \
  45. __gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
  46. ._ErrMsg._M_error()
  47. #endif
  48. #define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \
  49. do \
  50. { \
  51. _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); \
  52. } while (false)
  53. #define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \
  54. _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,__PRETTY_FUNCTION__)
  55. #define _GLIBCXX_DEBUG_VERIFY(_Cond,_ErrMsg) \
  56. _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond, _ErrMsg, __FILE__, __LINE__, \
  57. __PRETTY_FUNCTION__)
  58. // Verify that [_First, _Last) forms a valid iterator range.
  59. #define __glibcxx_check_valid_range(_First,_Last) \
  60. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
  61. _M_message(__gnu_debug::__msg_valid_range) \
  62. ._M_iterator(_First, #_First) \
  63. ._M_iterator(_Last, #_Last))
  64. #define __glibcxx_check_valid_range_at(_First,_Last,_File,_Line,_Func) \
  65. _GLIBCXX_DEBUG_VERIFY_AT_F(__gnu_debug::__valid_range(_First, _Last), \
  66. _M_message(__gnu_debug::__msg_valid_range) \
  67. ._M_iterator(_First, #_First) \
  68. ._M_iterator(_Last, #_Last), \
  69. _File,_Line,_Func)
  70. #define __glibcxx_check_valid_range2(_First,_Last,_Dist) \
  71. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last, _Dist), \
  72. _M_message(__gnu_debug::__msg_valid_range) \
  73. ._M_iterator(_First, #_First) \
  74. ._M_iterator(_Last, #_Last))
  75. #define __glibcxx_check_valid_constructor_range(_First,_Last) \
  76. __gnu_debug::__check_valid_range(_First, _Last, \
  77. __FILE__, __LINE__, __PRETTY_FUNCTION__)
  78. // Verify that [_First, _Last) forms a non-empty iterator range.
  79. #define __glibcxx_check_non_empty_range(_First,_Last) \
  80. _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
  81. _M_message(__gnu_debug::__msg_non_empty_range) \
  82. ._M_iterator(_First, #_First) \
  83. ._M_iterator(_Last, #_Last))
  84. // Verify that [_First, _First + _Size) forms a valid range.
  85. #define __glibcxx_check_can_increment(_First,_Size) \
  86. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__can_advance(_First, _Size), \
  87. _M_message(__gnu_debug::__msg_iter_subscript_oob) \
  88. ._M_iterator(_First, #_First) \
  89. ._M_integer(_Size, #_Size))
  90. #define __glibcxx_check_can_increment_range(_First1,_Last1,_First2) \
  91. do \
  92. { \
  93. typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\
  94. _GLIBCXX_DEBUG_VERIFY_COND_AT( \
  95. __gnu_debug::__valid_range(_First1, _Last1, __dist),\
  96. _M_message(__gnu_debug::__msg_valid_range) \
  97. ._M_iterator(_First1, #_First1) \
  98. ._M_iterator(_Last1, #_Last1), \
  99. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  100. _GLIBCXX_DEBUG_VERIFY_COND_AT( \
  101. __gnu_debug::__can_advance(_First2, __dist.first),\
  102. _M_message(__gnu_debug::__msg_iter_subscript_oob)\
  103. ._M_iterator(_First2, #_First2) \
  104. ._M_integer(__dist.first), \
  105. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  106. } while(false)
  107. #define __glibcxx_check_can_decrement_range(_First1,_Last1,_First2) \
  108. do \
  109. { \
  110. typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\
  111. _GLIBCXX_DEBUG_VERIFY_COND_AT( \
  112. __gnu_debug::__valid_range(_First1, _Last1, __dist),\
  113. _M_message(__gnu_debug::__msg_valid_range) \
  114. ._M_iterator(_First1, #_First1) \
  115. ._M_iterator(_Last1, #_Last1), \
  116. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  117. _GLIBCXX_DEBUG_VERIFY_COND_AT( \
  118. __gnu_debug::__can_advance(_First2, -__dist.first),\
  119. _M_message(__gnu_debug::__msg_iter_subscript_oob)\
  120. ._M_iterator(_First2, #_First2) \
  121. ._M_integer(-__dist.first), \
  122. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  123. } while(false)
  124. /** Verify that we can insert into *this with the iterator _Position.
  125. * Insertion into a container at a specific position requires that
  126. * the iterator be nonsingular, either dereferenceable or past-the-end,
  127. * and that it reference the sequence we are inserting into. Note that
  128. * this macro is only valid when the container is a_Safe_sequence and
  129. * the iterator is a _Safe_iterator.
  130. */
  131. #define __glibcxx_check_insert(_Position) \
  132. _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \
  133. _M_message(__gnu_debug::__msg_insert_singular) \
  134. ._M_sequence(*this, "this") \
  135. ._M_iterator(_Position, #_Position)); \
  136. _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
  137. _M_message(__gnu_debug::__msg_insert_different) \
  138. ._M_sequence(*this, "this") \
  139. ._M_iterator(_Position, #_Position))
  140. /** Verify that we can insert into *this after the iterator _Position.
  141. * Insertion into a container after a specific position requires that
  142. * the iterator be nonsingular, either dereferenceable or before-begin,
  143. * and that it reference the sequence we are inserting into. Note that
  144. * this macro is only valid when the container is a_Safe_sequence and
  145. * the iterator is a _Safe_iterator.
  146. */
  147. #define __glibcxx_check_insert_after(_Position) \
  148. __glibcxx_check_insert(_Position); \
  149. _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \
  150. _M_message(__gnu_debug::__msg_insert_after_end) \
  151. ._M_sequence(*this, "this") \
  152. ._M_iterator(_Position, #_Position))
  153. /** Verify that we can insert the values in the iterator range
  154. * [_First, _Last) into *this with the iterator _Position. Insertion
  155. * into a container at a specific position requires that the iterator
  156. * be nonsingular (i.e., either dereferenceable or past-the-end),
  157. * that it reference the sequence we are inserting into, and that the
  158. * iterator range [_First, _Last) is a valid (possibly empty)
  159. * range which does not reference the sequence we are inserting into.
  160. * Note that this macro is only valid when the container is a
  161. * _Safe_sequence and the _Position iterator is a _Safe_iterator.
  162. */
  163. #define __glibcxx_check_insert_range(_Position,_First,_Last,_Dist) \
  164. __glibcxx_check_valid_range2(_First,_Last,_Dist); \
  165. __glibcxx_check_insert(_Position); \
  166. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
  167. _M_message(__gnu_debug::__msg_insert_range_from_self)\
  168. ._M_iterator(_First, #_First) \
  169. ._M_iterator(_Last, #_Last) \
  170. ._M_sequence(*this, "this"))
  171. /** Verify that we can insert the values in the iterator range
  172. * [_First, _Last) into *this after the iterator _Position. Insertion
  173. * into a container after a specific position requires that the iterator
  174. * be nonsingular (i.e., either dereferenceable or past-the-end),
  175. * that it reference the sequence we are inserting into, and that the
  176. * iterator range [_First, _Last) is a valid (possibly empty)
  177. * range which does not reference the sequence we are inserting into.
  178. * Note that this macro is only valid when the container is a
  179. * _Safe_sequence and the _Position iterator is a _Safe_iterator.
  180. */
  181. #define __glibcxx_check_insert_range_after(_Position,_First,_Last,_Dist)\
  182. __glibcxx_check_valid_range2(_First,_Last,_Dist); \
  183. __glibcxx_check_insert_after(_Position); \
  184. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
  185. _M_message(__gnu_debug::__msg_insert_range_from_self)\
  186. ._M_iterator(_First, #_First) \
  187. ._M_iterator(_Last, #_Last) \
  188. ._M_sequence(*this, "this"))
  189. /** Verify that we can erase the element referenced by the iterator
  190. * _Position. We can erase the element if the _Position iterator is
  191. * dereferenceable and references this sequence.
  192. */
  193. #define __glibcxx_check_erase(_Position) \
  194. _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \
  195. _M_message(__gnu_debug::__msg_erase_bad) \
  196. ._M_sequence(*this, "this") \
  197. ._M_iterator(_Position, #_Position)); \
  198. _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
  199. _M_message(__gnu_debug::__msg_erase_different) \
  200. ._M_sequence(*this, "this") \
  201. ._M_iterator(_Position, #_Position))
  202. /** Verify that we can erase the element after the iterator
  203. * _Position. We can erase the element if the _Position iterator is
  204. * before a dereferenceable one and references this sequence.
  205. */
  206. #define __glibcxx_check_erase_after(_Position) \
  207. _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \
  208. _M_message(__gnu_debug::__msg_erase_after_bad) \
  209. ._M_sequence(*this, "this") \
  210. ._M_iterator(_Position, #_Position)); \
  211. _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
  212. _M_message(__gnu_debug::__msg_erase_different) \
  213. ._M_sequence(*this, "this") \
  214. ._M_iterator(_Position, #_Position))
  215. /** Verify that we can erase the elements in the iterator range
  216. * [_First, _Last). We can erase the elements if [_First, _Last) is a
  217. * valid iterator range within this sequence.
  218. */
  219. #define __glibcxx_check_erase_range(_First,_Last) \
  220. __glibcxx_check_valid_range(_First,_Last); \
  221. _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
  222. _M_message(__gnu_debug::__msg_erase_different) \
  223. ._M_sequence(*this, "this") \
  224. ._M_iterator(_First, #_First) \
  225. ._M_iterator(_Last, #_Last))
  226. /** Verify that we can erase the elements in the iterator range
  227. * (_First, _Last). We can erase the elements if (_First, _Last) is a
  228. * valid iterator range within this sequence.
  229. */
  230. #define __glibcxx_check_erase_range_after(_First,_Last) \
  231. _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \
  232. _M_message(__gnu_debug::__msg_erase_different) \
  233. ._M_sequence(*this, "this") \
  234. ._M_iterator(_First, #_First) \
  235. ._M_iterator(_Last, #_Last)); \
  236. _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
  237. _M_message(__gnu_debug::__msg_erase_different) \
  238. ._M_sequence(*this, "this") \
  239. ._M_iterator(_First, #_First)); \
  240. _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
  241. _M_message(__gnu_debug::__msg_valid_range2) \
  242. ._M_sequence(*this, "this") \
  243. ._M_iterator(_First, #_First) \
  244. ._M_iterator(_Last, #_Last)); \
  245. _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \
  246. _M_message(__gnu_debug::__msg_valid_range2) \
  247. ._M_sequence(*this, "this") \
  248. ._M_iterator(_First, #_First) \
  249. ._M_iterator(_Last, #_Last)); \
  250. _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
  251. _M_message(__gnu_debug::__msg_valid_range2) \
  252. ._M_sequence(*this, "this") \
  253. ._M_iterator(_First, #_First) \
  254. ._M_iterator(_Last, #_Last)) \
  255. // Verify that the subscript _N is less than the container's size.
  256. #define __glibcxx_check_subscript(_N) \
  257. _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
  258. _M_message(__gnu_debug::__msg_subscript_oob) \
  259. ._M_sequence(*this, "this") \
  260. ._M_integer(_N, #_N) \
  261. ._M_integer(this->size(), "size"))
  262. // Verify that the bucket _N is less than the container's buckets count.
  263. #define __glibcxx_check_bucket_index(_N) \
  264. _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \
  265. _M_message(__gnu_debug::__msg_bucket_index_oob) \
  266. ._M_sequence(*this, "this") \
  267. ._M_integer(_N, #_N) \
  268. ._M_integer(this->bucket_count(), "size"))
  269. // Verify that the container is nonempty
  270. #define __glibcxx_check_nonempty() \
  271. _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
  272. _M_message(__gnu_debug::__msg_empty) \
  273. ._M_sequence(*this, "this"))
  274. // Verify that a predicate is irreflexive
  275. #define __glibcxx_check_irreflexive(_First,_Last) \
  276. _GLIBCXX_DEBUG_VERIFY(_First == _Last || !(*_First < *_First), \
  277. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  278. ._M_iterator_value_type(_First, "< operator type"))
  279. #if __cplusplus >= 201103L
  280. # define __glibcxx_check_irreflexive2(_First,_Last) \
  281. _GLIBCXX_DEBUG_VERIFY(_First == _Last \
  282. || __gnu_debug::__is_irreflexive(_First), \
  283. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  284. ._M_iterator_value_type(_First, "< operator type"))
  285. #else
  286. # define __glibcxx_check_irreflexive2(_First,_Last)
  287. #endif
  288. #define __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) \
  289. _GLIBCXX_DEBUG_VERIFY(_First == _Last || !_Pred(*_First, *_First), \
  290. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  291. ._M_instance(_Pred, "functor") \
  292. ._M_iterator_value_type(_First, "ordered type"))
  293. #if __cplusplus >= 201103L
  294. # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) \
  295. _GLIBCXX_DEBUG_VERIFY(_First == _Last \
  296. ||__gnu_debug::__is_irreflexive_pred(_First, _Pred), \
  297. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  298. ._M_instance(_Pred, "functor") \
  299. ._M_iterator_value_type(_First, "ordered type"))
  300. #else
  301. # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred)
  302. #endif
  303. // Verify that the iterator range [_First, _Last) is sorted
  304. #define __glibcxx_check_sorted(_First,_Last) \
  305. __glibcxx_check_valid_range(_First,_Last); \
  306. __glibcxx_check_irreflexive(_First,_Last); \
  307. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
  308. __gnu_debug::__base(_First), \
  309. __gnu_debug::__base(_Last)), \
  310. _M_message(__gnu_debug::__msg_unsorted) \
  311. ._M_iterator(_First, #_First) \
  312. ._M_iterator(_Last, #_Last))
  313. /** Verify that the iterator range [_First, _Last) is sorted by the
  314. predicate _Pred. */
  315. #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
  316. __glibcxx_check_valid_range(_First,_Last); \
  317. __glibcxx_check_irreflexive_pred(_First,_Last,_Pred); \
  318. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
  319. __gnu_debug::__base(_First), \
  320. __gnu_debug::__base(_Last), _Pred), \
  321. _M_message(__gnu_debug::__msg_unsorted_pred) \
  322. ._M_iterator(_First, #_First) \
  323. ._M_iterator(_Last, #_Last) \
  324. ._M_string(#_Pred))
  325. // Special variant for std::merge, std::includes, std::set_*
  326. #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
  327. __glibcxx_check_valid_range(_First1,_Last1); \
  328. _GLIBCXX_DEBUG_VERIFY( \
  329. __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
  330. __gnu_debug::__base(_Last1), _First2),\
  331. _M_message(__gnu_debug::__msg_unsorted) \
  332. ._M_iterator(_First1, #_First1) \
  333. ._M_iterator(_Last1, #_Last1))
  334. // Likewise with a _Pred.
  335. #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
  336. __glibcxx_check_valid_range(_First1,_Last1); \
  337. _GLIBCXX_DEBUG_VERIFY( \
  338. __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
  339. __gnu_debug::__base(_Last1), \
  340. _First2, _Pred), \
  341. _M_message(__gnu_debug::__msg_unsorted_pred) \
  342. ._M_iterator(_First1, #_First1) \
  343. ._M_iterator(_Last1, #_Last1) \
  344. ._M_string(#_Pred))
  345. /** Verify that the iterator range [_First, _Last) is partitioned
  346. w.r.t. the value _Value. */
  347. #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
  348. __glibcxx_check_valid_range(_First,_Last); \
  349. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
  350. __gnu_debug::__base(_First), \
  351. __gnu_debug::__base(_Last), _Value), \
  352. _M_message(__gnu_debug::__msg_unpartitioned) \
  353. ._M_iterator(_First, #_First) \
  354. ._M_iterator(_Last, #_Last) \
  355. ._M_string(#_Value))
  356. #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
  357. __glibcxx_check_valid_range(_First,_Last); \
  358. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
  359. __gnu_debug::__base(_First), \
  360. __gnu_debug::__base(_Last), _Value), \
  361. _M_message(__gnu_debug::__msg_unpartitioned) \
  362. ._M_iterator(_First, #_First) \
  363. ._M_iterator(_Last, #_Last) \
  364. ._M_string(#_Value))
  365. /** Verify that the iterator range [_First, _Last) is partitioned
  366. w.r.t. the value _Value and predicate _Pred. */
  367. #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
  368. __glibcxx_check_valid_range(_First,_Last); \
  369. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
  370. __gnu_debug::__base(_First), \
  371. __gnu_debug::__base(_Last), _Value, _Pred), \
  372. _M_message(__gnu_debug::__msg_unpartitioned_pred) \
  373. ._M_iterator(_First, #_First) \
  374. ._M_iterator(_Last, #_Last) \
  375. ._M_string(#_Pred) \
  376. ._M_string(#_Value))
  377. /** Verify that the iterator range [_First, _Last) is partitioned
  378. w.r.t. the value _Value and predicate _Pred. */
  379. #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
  380. __glibcxx_check_valid_range(_First,_Last); \
  381. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
  382. __gnu_debug::__base(_First), \
  383. __gnu_debug::__base(_Last), _Value, _Pred), \
  384. _M_message(__gnu_debug::__msg_unpartitioned_pred) \
  385. ._M_iterator(_First, #_First) \
  386. ._M_iterator(_Last, #_Last) \
  387. ._M_string(#_Pred) \
  388. ._M_string(#_Value))
  389. // Verify that the iterator range [_First, _Last) is a heap
  390. #define __glibcxx_check_heap(_First,_Last) \
  391. _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
  392. __gnu_debug::__base(_Last)), \
  393. _M_message(__gnu_debug::__msg_not_heap) \
  394. ._M_iterator(_First, #_First) \
  395. ._M_iterator(_Last, #_Last))
  396. /** Verify that the iterator range [_First, _Last) is a heap
  397. w.r.t. the predicate _Pred. */
  398. #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
  399. _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
  400. __gnu_debug::__base(_Last), \
  401. _Pred), \
  402. _M_message(__gnu_debug::__msg_not_heap_pred) \
  403. ._M_iterator(_First, #_First) \
  404. ._M_iterator(_Last, #_Last) \
  405. ._M_string(#_Pred))
  406. // Verify that the container is not self move assigned
  407. #define __glibcxx_check_self_move_assign(_Other) \
  408. _GLIBCXX_DEBUG_VERIFY(this != &_Other, \
  409. _M_message(__gnu_debug::__msg_self_move_assign) \
  410. ._M_sequence(*this, "this"))
  411. // Verify that load factor is positive
  412. #define __glibcxx_check_max_load_factor(_F) \
  413. _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \
  414. _M_message(__gnu_debug::__msg_valid_load_factor) \
  415. ._M_sequence(*this, "this"))
  416. #define __glibcxx_check_equal_allocs(_This, _Other) \
  417. _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \
  418. _M_message(__gnu_debug::__msg_equal_allocs) \
  419. ._M_sequence(_This, "this"))
  420. #define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
  421. #define __glibcxx_check_string_len(_String,_Len) \
  422. _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
  423. #endif