From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7814) id 15AA63858031; Sat, 28 Aug 2021 00:41:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15AA63858031 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Fangrui Song To: glibc-cvs@sourceware.org Subject: [glibc/google/grte/v5-2.27/master] Work around clang mishandling of assert functions in resolver buffer allocation, fixes random error X-Act-Checkin: glibc X-Git-Author: Stan Shebs X-Git-Refname: refs/heads/google/grte/v5-2.27/master X-Git-Oldrev: 8254ee748c227f5921d28dd5fece73b20fde50f7 X-Git-Newrev: 090479eb8ce8eecbcb78a72b8070549762f80c1b Message-Id: <20210828004149.15AA63858031@sourceware.org> Date: Sat, 28 Aug 2021 00:41:49 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 00:41:49 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=090479eb8ce8eecbcb78a72b8070549762f80c1b commit 090479eb8ce8eecbcb78a72b8070549762f80c1b Author: Stan Shebs Date: Fri Apr 20 14:44:54 2018 -0700 Work around clang mishandling of assert functions in resolver buffer allocation, fixes random error returns in resolv/ tests. Diff: --- include/alloc_buffer.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/alloc_buffer.h b/include/alloc_buffer.h index 4167584f6f..a06980e6d2 100644 --- a/include/alloc_buffer.h +++ b/include/alloc_buffer.h @@ -213,6 +213,10 @@ alloc_buffer_alloc_bytes (struct alloc_buffer *buf, size_t length) static __always_inline size_t __alloc_buffer_assert_size (size_t size) { + /* clang does not presently support the __error__ attribute, and for + some reason the fallback case for __errordecl results in error() + being called unconditionally. So skip over this for now. */ +#ifndef __clang__ if (!__builtin_constant_p (size)) { __errordecl (error, "type size is not constant"); @@ -223,6 +227,7 @@ __alloc_buffer_assert_size (size_t size) __errordecl (error, "type size is zero"); error (); } +#endif return size; } @@ -231,6 +236,8 @@ __alloc_buffer_assert_size (size_t size) static __always_inline size_t __alloc_buffer_assert_align (size_t align) { + /* As above - skip until we have a better idea for clang here. */ +#ifndef __clang__ if (!__builtin_constant_p (align)) { __errordecl (error, "type alignment is not constant"); @@ -246,6 +253,7 @@ __alloc_buffer_assert_align (size_t align) __errordecl (error, "type alignment is not a power of two"); error (); } +#endif return align; }