bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* lib/unistr/u8-uctomb.c fails to compile
@ 2020-01-20 16:27 Andreas Schwab
  2020-01-20 17:48 ` warning in lib/unistr/u8-uctomb.c Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2020-01-20 16:27 UTC (permalink / raw)
  To: bug-grep; +Cc: bug-gnulib

../../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@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: warning in lib/unistr/u8-uctomb.c
  2020-01-20 16:27 lib/unistr/u8-uctomb.c fails to compile Andreas Schwab
@ 2020-01-20 17:48 ` Bruno Haible
  2020-01-21  8:48   ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2020-01-20 17:48 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Andreas Schwab, bug-grep

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@clisp.org>

	unistr/u8-uctomb: Fix warning.
	Reported by Andreas Schwab <schwab@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;
             }



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: warning in lib/unistr/u8-uctomb.c
  2020-01-20 17:48 ` warning in lib/unistr/u8-uctomb.c Bruno Haible
@ 2020-01-21  8:48   ` Andreas Schwab
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2020-01-21  8:48 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-grep, bug-gnulib

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@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-21  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 16:27 lib/unistr/u8-uctomb.c fails to compile Andreas Schwab
2020-01-20 17:48 ` warning in lib/unistr/u8-uctomb.c Bruno Haible
2020-01-21  8:48   ` 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).