* Fix iconv build with GCC mainline
@ 2021-08-19 16:56 Joseph Myers
2021-08-23 15:46 ` Ping " Joseph Myers
2021-08-23 16:09 ` Andreas Schwab
0 siblings, 2 replies; 3+ messages in thread
From: Joseph Myers @ 2021-08-19 16:56 UTC (permalink / raw)
To: libc-alpha
Current GCC mainline produces -Wstringop-overflow errors building some
iconv converters, as discussed at
<https://gcc.gnu.org/pipermail/gcc/2021-July/236943.html>. 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
<https://sourceware.org/pipermail/libc-alpha/2021-August/130244.html>,
it restores the glibc build for powerpc-linux-gnu.
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);
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Ping Re: Fix iconv build with GCC mainline
2021-08-19 16:56 Fix iconv build with GCC mainline Joseph Myers
@ 2021-08-23 15:46 ` Joseph Myers
2021-08-23 16:09 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Joseph Myers @ 2021-08-23 15:46 UTC (permalink / raw)
To: libc-alpha
Ping. This patch
<https://sourceware.org/pipermail/libc-alpha/2021-August/130315.html> is
pending review.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix iconv build with GCC mainline
2021-08-19 16:56 Fix iconv build with GCC mainline Joseph Myers
2021-08-23 15:46 ` Ping " Joseph Myers
@ 2021-08-23 16:09 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2021-08-23 16:09 UTC (permalink / raw)
To: Joseph Myers; +Cc: libc-alpha
On Aug 19 2021, Joseph Myers wrote:
> Current GCC mainline produces -Wstringop-overflow errors building some
> iconv converters, as discussed at
> <https://gcc.gnu.org/pipermail/gcc/2021-July/236943.html>. 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.
Ok.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-23 16:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 16:56 Fix iconv build with GCC mainline Joseph Myers
2021-08-23 15:46 ` Ping " Joseph Myers
2021-08-23 16:09 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).