Suppress compiler warnings with __builtin_unreachable #217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements the idea suggested in #208.
Summary by Copilot
This pull request replaces all instances of the
assert(false)pattern with a newUNREACHABLE()macro throughout the codebase. TheUNREACHABLE()macro provides a clearer indication of unreachable code and, when supported, uses compiler intrinsics to mark such code paths as unreachable, potentially aiding optimization and diagnostics. The macro is defined incommon.hand is now used in place ofassert(false)in various source files.Macro introduction and usage update:
UNREACHABLE()macro incommon.h, which asserts and uses__builtin_unreachable()when available, otherwise just asserts.assert(false)withUNREACHABLE()in logic branches that should never be reached, across multiple files includingarith.c,builtin.c,builtins/printf.c,builtins/test.c,exec.c,expand.c, andhistory.c. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35]Copyright update:
arith.candcommon.hto 2025. [1] [2]This change improves code clarity and maintainability by standardizing unreachable code handling and leveraging compiler features where available.