From 532b4c9f21473559657e273ef9f8f6fc8c7c2ab1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 26 Feb 2022 11:39:32 -0800 Subject: [PATCH] Document clang -fsanitize=undefined glitch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/gnulib-intro.texi (Unsupported Platforms): Document incompatibility of ‘clang -fsanitize=undefined’ with Gnulib, and how to work around it by also using ‘-fno-sanitize=pointer-overflow’. --- ChangeLog | 8 ++++++++ doc/gnulib-intro.texi | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6daf85da3e..430f81fd39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2022-02-26 Paul Eggert + + Document clang -fsanitize=undefined glitch + * doc/gnulib-intro.texi (Unsupported Platforms): + Document incompatibility of ‘clang -fsanitize=undefined’ + with Gnulib, and how to work around it by also using + ‘-fno-sanitize=pointer-overflow’. + 2022-02-25 Darshit Shah modules/unicase/special-casing: Fix compilation error diff --git a/doc/gnulib-intro.texi b/doc/gnulib-intro.texi index a80c0995f5..0bc9701561 100644 --- a/doc/gnulib-intro.texi +++ b/doc/gnulib-intro.texi @@ -235,6 +235,17 @@ and Gnulib-using code would have if it were intended to be portable to all practical POSIX or C platforms. @itemize @bullet +@item +Clang's @option{-fsanitize=undefined} option causes the program to +crash if it adds zero to a null pointer -- behavior that is undefined +in strict C, but which yields a null pointer on all practical porting +targets and which the Gnulib portability guidelines allow. + +If you use Clang with @option{-fsanitize=undefined}, you can work +around the problem by also using @samp{-fno-sanitize=pointer-overflow}, +although this may also disable some unrelated and useful pointer checks. +Perhaps someday the Clang developers will fix the infelicity. + @item The IBM i's pointers are 128 bits wide and it lacks the two types @code{intptr_t} and @code{uintptr_t}, which are optional in the C and -- 2.32.0