On 3/18/25 11:42, Kaz Kylheku wrote:
in the case of Clang, we cannot look to its offsetof
definition to hypothesize that it has a null pointer arithmetic
extension.

Yes, and 'clang -fsanitize=undefined' reports a runtime error if you add 0 to a null pointer. However, Gnulib is documented to rely on adding 0 to a null pointer, and our response has consistently been "Don't use Clang that way".

This is not the only place that Gnulib doesn't strictly conform to C, and it's not an area that we should need to worry about. Once C2y comes out and says it's OK to add 0 to a null pointer, the clang -fsanitize=undefined issue should go away. In the meantime, one should not use clang -fsanitize=undefined in production code (there are other good reasons for this).

Luckily, 'gcc -fsanitize=undefined' doesn't have the problem.

Reply via email to