0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-11-08 23:27:15 -05:00

compiler: add and use unreachable() macro

C23 defines unreachable() as a macro in <stddef.h>. For earlier
versions of gcc, __builtin_unreachable() is possible.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel)
2025-10-13 17:53:42 -07:00
parent 9ba21c1e50
commit 44ec97993a
4 changed files with 36 additions and 20 deletions

View File

@@ -469,4 +469,12 @@ static inline unsigned int watcom_switch_hack(uint64_t x)
# define default case BOGUS_CASE: default
#endif
#ifndef unreachable /* C23 defines as a macro in <stddef.h> */
# ifdef HAVE___BUILTIN_UNREACHABLE
# define unreachable() __builtin_unreachable()
# else
# define unreachable() do { abort(); } while(1)
# endif
#endif
#endif /* NASM_COMPILER_H */