diff --git a/include/haproxy/compiler.h b/include/haproxy/compiler.h index c19d2c46a..fc7679e8a 100644 --- a/include/haproxy/compiler.h +++ b/include/haproxy/compiler.h @@ -523,4 +523,15 @@ #define __has_feature(x) 0 #endif +/* gcc 15 throws warning if fixed-size char array does not contain a terminating + * NUL. gcc has an attribute 'nonstring', which allows to suppress this warning + * for such array declarations. But it's not the case for clang and other + * compilers. + */ +#if __has_attribute(nonstring) +#define __nonstring __attribute__ ((nonstring)) +#else +#define __nonstring +#endif + #endif /* _HAPROXY_COMPILER_H */ diff --git a/src/tools.c b/src/tools.c index ce927f90c..5cd89be9f 100644 --- a/src/tools.c +++ b/src/tools.c @@ -65,6 +65,7 @@ extern void *__elf_aux_vector; #include #include #include +#include #include #include #include @@ -2038,7 +2039,7 @@ int addr_is_local(const struct netns_entry *ns, * * Return the address of the \0 character, or NULL on error */ -const char hextab[16] = "0123456789ABCDEF"; +const char hextab[16] __nonstring = "0123456789ABCDEF"; char *encode_string(char *start, char *stop, const char escape, const long *map, const char *string)