https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96987
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- A void pointer is usually cast to one to a complete type that's then used to access the object (e.g., bsearch). But not every instance of every warning should be expected to indicate a bug. Most only suggest that there might be one. The documented purpose of GCC warnings is to "report constructions that are not inherently erroneous but that are risky or suggest there may have been an error." This rare use is one such case. It was considered when the warning was designed and deemed an acceptable trade-off. (The attribute was added to help accommodate it.) If adding support for attribute access to the D front end isn't feasible to mark up the function and avoid the warning that way, I would suggest removing the const qualifier from the pointer (following the practice of the C++ standard garbage collector APIs) or providing an non-const overload. Alternatively, writing into a byte of the allocated memory will prevent the warning as well.