From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1105) id 659BE3858C2C; Mon, 23 Aug 2021 16:18:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 659BE3858C2C Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Joseph Myers To: glibc-cvs@sourceware.org Subject: [glibc] Fix iconv build with GCC mainline X-Act-Checkin: glibc X-Git-Author: Joseph Myers X-Git-Refname: refs/heads/master X-Git-Oldrev: a4f5a3103fc3e7974dbe35b411cba9f670807cde X-Git-Newrev: c8126360dfa98024cc40bce915e126309993cdf9 Message-Id: <20210823161856.659BE3858C2C@sourceware.org> Date: Mon, 23 Aug 2021 16:18:56 +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: Mon, 23 Aug 2021 16:18:56 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c8126360dfa98024cc40bce915e126309993cdf9 commit c8126360dfa98024cc40bce915e126309993cdf9 Author: Joseph Myers Date: Mon Aug 23 16:18:42 2021 +0000 Fix iconv build with GCC mainline Current GCC mainline produces -Wstringop-overflow errors building some iconv converters, as discussed at . Add an __builtin_unreachable call as suggested so that GCC can see the case that would involve a buffer overflow is unreachable; because the unreachability depends on valid conversion state being passed into the function from previous conversion steps, it's not something the compiler can reasonably deduce on its own. Tested with build-many-glibcs.py that, together with , it restores the glibc build for powerpc-linux-gnu. Diff: --- iconv/loop.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iconv/loop.c b/iconv/loop.c index 062cc1b868..560a5f6394 100644 --- a/iconv/loop.c +++ b/iconv/loop.c @@ -436,6 +436,12 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, return __GCONV_FULL_OUTPUT; /* Now add characters from the normal input buffer. */ + if (inlen >= MAX_NEEDED_INPUT) + /* Avoid a -Wstringop-overflow= warning when this loop is + unrolled. The compiler cannot otherwise see that this is + unreachable because it depends on (state->__count & 7) not + being too large after a previous conversion step. */ + __builtin_unreachable (); do bytebuf[inlen++] = *inptr++; while (inlen < MAX_NEEDED_INPUT && inptr < inend);