From 9248a85f97e370eae69a9c6e58ab151318c0e902 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin (Intel)" Date: Tue, 7 Jul 2026 15:06:21 -0700 Subject: [PATCH] asm/error.c: handle -w* during command line parsing During command line parsing, warning_state_init is NULL as the warning stack is naturally not set up yet. Furthermore, -w* would mean return to command-line default, which isn't even defined yet. Rather than ignoring it or returning an error, do something useful by allowing -w* to reset to the *compile time* default when specified on the command line. Reported-by: Fixes: https://github.com/netwide-assembler/nasm/issues/155 Signed-off-by: H. Peter Anvin (Intel) --- asm/error.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/asm/error.c b/asm/error.c index 77f498389..f4882d858 100644 --- a/asm/error.c +++ b/asm/error.c @@ -214,10 +214,18 @@ bool set_warning_status(const char *value) warning_state[i] |= mask; break; case WID_RESET: + { + uint8_t old; + if (warning_state_init) + old = warning_state_init->state[i]; + else + old = warning_default[i]; + warning_state[i] &= ~mask; - warning_state[i] |= warning_state_init->state[i] & mask; + warning_state[i] |= old & mask; break; } + } } if (!ok && value) {