1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified Sat Jul 24 21:42:42 1993 by Rik Faith <faith@cs.unc.edu>
26 .\" Modified Tue Oct 22 23:44:11 1996 by Eric S. Raymond <esr@thyrsus.com>
27 .\" Modified Thu Jun 2 23:44:11 2016 by Nikos Mavrogiannopoulos <nmav@redhat.com>
28 .TH ASSERT 3 2021-03-22 "GNU" "Linux Programmer's Manual"
30 assert \- abort the program if assertion is false
33 .B #include <assert.h>
35 .BI "void assert(scalar " expression );
38 This macro can help programmers find bugs in their programs,
39 or handle exceptional cases
40 via a crash that will produce limited debugging output.
44 is false (i.e., compares equal to zero),
46 prints an error message to standard error
47 and terminates the program by calling
49 The error message includes the name of the file and function containing the
51 call, the source code line number of the call, and the text of the argument;
56 prog: some_file.c:16: some_func: Assertion \`val == 0\(aq failed.
62 is defined at the moment
64 was last included, the macro
66 generates no code, and hence does nothing at all.
67 It is not recommended to define
71 to detect error conditions since the software
72 may behave non-deterministically.
76 For an explanation of the terms used in this section, see
84 Interface Attribute Value
87 T} Thread safety MT-Safe
93 POSIX.1-2001, POSIX.1-2008, C89, C99.
96 is required to be of type
98 and undefined behavior results if it is not, but in C99
99 it may have any scalar type.
100 .\" See Defect Report 107 for more details.
103 is implemented as a macro; if the expression tested has side-effects,
104 program behavior will be different depending on whether
107 This may create Heisenbugs which go away when debugging
111 .BR assert_perror (3),