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