GNU bug report logs - #39206
lib/unistr/u8-uctomb.c fails to compile

Previous Next

Package: grep;

Reported by: Andreas Schwab <schwab <at> suse.de>

Date: Mon, 20 Jan 2020 16:29:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39206 in the body.
You can then email your comments to 39206 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#39206; Package grep. (Mon, 20 Jan 2020 16:29:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Schwab <schwab <at> suse.de>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Mon, 20 Jan 2020 16:29:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: bug-grep <at> gnu.org
Cc: bug-gnulib <at> gnu.org
Subject: lib/unistr/u8-uctomb.c fails to compile
Date: Mon, 20 Jan 2020 17:27:46 +0100
../../grep/lib/unistr/u8-uctomb.c: In function 'u8_uctomb':
../../grep/lib/unistr/u8-uctomb.c:64:65: error: this statement may fall through [-Werror=implicit-fallthrough=]
             case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
                                                              ~~~^~~~~~~~~~
../../grep/lib/unistr/u8-uctomb.c:65:13: note: here
             case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
             ^~~~
../../grep/lib/unistr/u8-uctomb.c:65:65: error: this statement may fall through [-Werror=implicit-fallthrough=]
             case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
                                                              ~~~^~~~~~~~
../../grep/lib/unistr/u8-uctomb.c:66:13: note: here
             case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
             ^~~~
cc1: all warnings being treated as errors

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-grep <at> gnu.org:
bug#39206; Package grep. (Mon, 20 Jan 2020 17:49:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Bruno Haible <bruno <at> clisp.org>
To: bug-gnulib <at> gnu.org
Cc: Andreas Schwab <schwab <at> suse.de>, bug-grep <at> gnu.org
Subject: Re: warning in lib/unistr/u8-uctomb.c
Date: Mon, 20 Jan 2020 18:48:35 +0100
Correcting the subject.

> cc1: all warnings being treated as errors

"this statement may fall through" is a warning. *You* turned it into an
error by using -Werror or -Werror=implicit-fallthrough. It is therefore
misleading to say that there is a compilation error in lib/unistr/u8-uctomb.c.

> ../../grep/lib/unistr/u8-uctomb.c: In function 'u8_uctomb':
> ../../grep/lib/unistr/u8-uctomb.c:64:65: error: this statement may fall through [-Werror=implicit-fallthrough=]
>              case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
>                                                               ~~~^~~~~~~~~~
> ../../grep/lib/unistr/u8-uctomb.c:65:13: note: here
>              case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
>              ^~~~
> ../../grep/lib/unistr/u8-uctomb.c:65:65: error: this statement may fall through [-Werror=implicit-fallthrough=]
>              case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
>                                                               ~~~^~~~~~~~
> ../../grep/lib/unistr/u8-uctomb.c:66:13: note: here
>              case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
>              ^~~~

Fixed through the patch below.

But something is wrong with the way you build packages: This code is only seen
by the compiler when HAVE_INLINE is undefined or 0. So, apparently the
autoconfiguration determined that the compiler does not support the 'inline'
keyword. Since the compiler is clang, this finding is not true.

Most likely, you had -Werror in $CC $CFLAGS already during configuration
time. This is NOT SUPPORTED, since it causes many configure tests to produce
wrong results.


2020-01-20  Bruno Haible  <bruno <at> clisp.org>

	unistr/u8-uctomb: Fix warning.
	Reported by Andreas Schwab <schwab <at> suse.de> in
	<https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00127.html>.
	* lib/unistr/u8-uctomb.c (FALLTHROUGH): New macro.
	(u8_uctomb): Add FALLTHROUGH markers.

diff --git a/lib/unistr/u8-uctomb.c b/lib/unistr/u8-uctomb.c
index f093822..d998002 100644
--- a/lib/unistr/u8-uctomb.c
+++ b/lib/unistr/u8-uctomb.c
@@ -25,6 +25,14 @@
 /* Specification.  */
 #include "unistr.h"
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 #if !HAVE_INLINE
 
 int
@@ -62,7 +70,9 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
           switch (count) /* note: code falls through cases! */
             {
             case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
+              FALLTHROUGH;
             case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
+              FALLTHROUGH;
             case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
           /*case 1:*/ s[0] = uc;
             }





Information forwarded to bug-grep <at> gnu.org:
bug#39206; Package grep. (Tue, 21 Jan 2020 08:50:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: Bruno Haible <bruno <at> clisp.org>
Cc: bug-grep <at> gnu.org, bug-gnulib <at> gnu.org
Subject: Re: warning in lib/unistr/u8-uctomb.c
Date: Tue, 21 Jan 2020 09:48:46 +0100
On Jan 20 2020, Bruno Haible wrote:

> "this statement may fall through" is a warning. *You* turned it into an
> error by using -Werror or -Werror=implicit-fallthrough.

Nope.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Mon, 21 Sep 2020 19:12:02 GMT) Full text and rfc822 format available.

Notification sent to Andreas Schwab <schwab <at> suse.de>:
bug acknowledged by developer. (Mon, 21 Sep 2020 19:12:02 GMT) Full text and rfc822 format available.

Message #16 received at 39206-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 39206-done <at> debbugs.gnu.org
Subject: Re: lib/unistr/u8-uctomb.c fails to compile
Date: Mon, 21 Sep 2020 12:11:42 -0700
As the bug appears to have been fixed I'm closing the bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Oct 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 160 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.