diff --git a/share/man/man3/unreachable.3 b/share/man/man3/unreachable.3 index 8a1c2d142578..9dd7da806d42 100644 --- a/share/man/man3/unreachable.3 +++ b/share/man/man3/unreachable.3 @@ -1,89 +1,90 @@ .\" .\" Copyright (c) 2025 Robert Clausecker .\" .\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd November 27, 2025 .Dt UNREACHABLE 3 .Os .Sh NAME .Nm unreachable .Nd the unreachable macro .Sh SYNOPSIS .In stddef.h .Fd #define unreachable() .Sh DESCRIPTION If the .Fn unreachable macro is reached during execution, behavior is undefined. This can be useful to hint to the compiler that some invariant is guaranteed to hold or that some case cannot occur. .Sh EXAMPLES Suppose a floating-point number .Va x is to be classified using the .Xr fpclassify 3 macro and a different action is to be taken based on the result of the classification. As the set of possible return values is known, the .Fn unreachable macro can be used to hint to the compiler that it can omit checks for other possible return values: .Bd -literal -offset 3n #include #include #include void print_classification(double x) { printf("%f: ", x); switch (fpclassify(x)) { case FP_INFINITE: puts("infinite"); break; case FP_NAN: puts("not a number"); break; case FP_NORMAL: puts("normal"); break; case FP_SUBNORMAL: puts("subnormal"); break; case FP_ZERO: puts("zero"); break; default: unreachable(); + } } .Ed .Sh SEE ALSO .Xr assert 3 .Sh STANDARDS The .Fn unreachable macro conforms to .St -isoC-2023 . .Sh HISTORY A .Dv /*NOTREACHED*/ conventional comment was supported by the historical .Xr lint 1 utility to suppress warnings about unreachable statements during static analysis. The .Fn unreachable macro was added in .Fx 15.1 based on the earlier private .Fn __unreachable macro for compliance with .St -isoC-2023 . .Sh AUTHOR .Ah Robert Clausecker Aq Mt fuz@FreeBSD.org