mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
Revert "stddef.h: add unreachable() for C23 compliance"
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
Seems like a number of ports are *really* unhappy with this new
macro. These ports will have to be fixed and the patch reworked
to perhaps not affect C++ (see D54041). A general discussion on
how we expose new language features may also need to take place.
Reported by: many people
Approved by: markj (mentor)
This reverts commit b381d09802.
This commit is contained in:
parent
8102307c7b
commit
fc88be257e
4 changed files with 3 additions and 99 deletions
|
|
@ -61,10 +61,6 @@ typedef __max_align_t max_align_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if __ISO_C_VISIBLE >= 2023
|
||||
#define unreachable(x) __unreachable(x)
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, field) __builtin_offsetof(type, field)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ MAN= alloca.3 \
|
|||
sysexits.3 \
|
||||
tgmath.3 \
|
||||
timeradd.3 \
|
||||
tree.3 \
|
||||
unreachable.3
|
||||
tree.3
|
||||
|
||||
MLINKS= arb.3 ARB8_ENTRY.3 \
|
||||
arb.3 ARB8_HEAD.3 \
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd November 27, 2025
|
||||
.Dd April 20, 2021
|
||||
.Dt ASSERT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -118,8 +118,7 @@ constraint and includes the provided string literal:
|
|||
If none is provided, it only points at the constraint.
|
||||
.Sh SEE ALSO
|
||||
.Xr abort2 2 ,
|
||||
.Xr abort 3 ,
|
||||
.Xr unreachable 3
|
||||
.Xr abort 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn assert
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
.\"
|
||||
.\" Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
|
||||
.\"
|
||||
.\" 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 <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
Loading…
Add table
Reference in a new issue