When using an sd_substring expression as argument to an sd_last_index
invocation, I see this warning:
../gnulib-lib/string-desc.h:589:17: warning: declaration of '_s_' shadows a
previous local [-Wshadow=compatible-local]
589 | ({typeof (s) _s_ = (s); \
| ^~~
../gnulib-lib/string-desc.h:539:24: note: in definition of macro 'sd_last_index'
539 | ({typeof (s) _s_ = (s); \
| ^
This patch fixes it. Not perfect, but good enough.
2026-10-31 Bruno Haible <[email protected]>
string-desc: Avoid a gcc -Wshadow=compatible-local warning.
* lib/string-desc.h (sd_substring): Rename local variable _s_ to _ss_.
diff --git a/lib/string-desc.h b/lib/string-desc.h
index 0e87c4d641..2ae167527c 100644
--- a/lib/string-desc.h
+++ b/lib/string-desc.h
@@ -586,15 +586,15 @@ extern rw_string_desc_t _rwsd_new_addr (idx_t n,
/*!*/const/*!*/ char *addr)
#if HAVE_RW_STRING_DESC
# define sd_substring(s, start, end) \
- ({typeof (s) _s_ = (s); \
+ ({typeof (s) _ss_ = (s); \
idx_t _start_ = (start); \
idx_t _end_ = (end); \
- if (!(_start_ >= 0 && _start_ <= _end_ && _end_ <= _s_._nbytes)) \
+ if (!(_start_ >= 0 && _start_ <= _end_ && _end_ <= _ss_._nbytes)) \
/* Invalid arguments. */ \
abort (); \
typeof (s) _result_; \
_result_._nbytes = _end_ - _start_; \
- _result_._data = _s_._data + _start_; \
+ _result_._data = _ss_._data + _start_; \
_result_; \
})
#else