>From 45e72160bebba64532ffc8dddf34a0882bcaa110 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 May 2020 17:07:47 -0700 Subject: [PATCH] careadlinkat: limit GCC workaround * lib/careadlinkat.c (careadlinkat): Limit workaround to GCC 10.1.0 and later, since the workaround is pretty bad and the GCC bug should get fixed. --- ChangeLog | 7 +++++++ lib/careadlinkat.c | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ef88249c..7468718c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-05-10 Paul Eggert + + careadlinkat: limit GCC workaround + * lib/careadlinkat.c (careadlinkat): Limit workaround to GCC + 10.1.0 and later, since the workaround is pretty bad and the GCC + bug should get fixed. + 2020-05-10 Bruno Haible havelib: Enhance documentation. diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c index e1f8305e9..fbed634f9 100644 --- a/lib/careadlinkat.c +++ b/lib/careadlinkat.c @@ -71,9 +71,14 @@ careadlinkat (int fd, char const *filename, size_t buf_size_max = SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; -#if defined GCC_LINT || defined lint +#if (defined GCC_LINT || defined lint) && _GL_GNUC_PREREQ (10, 1) /* Pacify preadlinkat without creating a pointer to the stack - that gcc -Wreturn-local-addr would cry wolf about. */ + that a broken gcc -Wreturn-local-addr would cry wolf about. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044 + This workaround differs substantially from the mainline code, but + no other way to pacify GCC 10.1.0 is known; even an explicit + #pragma does not pacify GCC. When the GCC bug is fixed this + workaround should be limited to the broken GCC versions. */ static char initial_buf[1]; enum { initial_buf_size = 0 }; /* 0 so that initial_buf never changes. */ #else -- 2.17.1