Skip to content

Commit e8eccaf

Browse files
committed
Annotate non NUL-terminated character array
The lookup table in hexchar() is of the size of its number of elements and thus not implicitly NUL-terminated. Add the nonstring annotation to please GCC 15: ../src/share/hexdecoct.c: In function ‘hexchar’: ../src/share/hexdecoct.c:38:39: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (17 chars into 16 available) [-Wunterminated-string-initialization] 38 | static const char table[16] = "0123456789abcdef"; | ^~~~~~~~~~~~~~~~~~
1 parent 547c2cd commit e8eccaf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/share/hexdecoct.c

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int undecchar(char c) {
3535
}
3636

3737
char hexchar(int x) {
38+
__attribute__ ((nonstring))
3839
static const char table[16] = "0123456789abcdef";
3940

4041
return table[x & 15];

0 commit comments

Comments
 (0)