Hello.
On Thu, Apr 16, 2026 at 06:12:24PM +1000, Seth McDonald via isync-devel wrote:
> The derivation of B from A thus requires casting away the const, which
> produces a compilation warning in environments using our memrchr()
> implementation. For all intents and purposes this warning is
> unavoidable, so locally supress it for the relevant cast.
...
> void *
> memrchr( const void *s, int c, size_t n )
> {
> +DIAG_PUSH
> +DIAG_DISABLE("-Wcast-qual")
> u_char *b = (u_char *)s, *e = b + n;
> +DIAG_POP
>
> while (--e >= b)
> if (*e == c)
BTW, there is a compiler-independent way to suppress such warning:
union { u_char *b; const void *cvoid_b; } ub;
ub.cvoid_b = s;
u_char *e = ub.b + n;
while (--e >= ub.b)
if (*e == c)
...
It assumes that pointers to all bare types are represented identically,
AFAIK, this is true for all existent C implementations.
--
Eugene Berdnikov
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel