-
Notifications
You must be signed in to change notification settings - Fork 577
stadtx_hash.h: Silence -Wimplicit-fallthrough compilation warnings #16206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From @jkeenanWhen building perl with gcc-7.2, many new compiler warnings are thrown. http://perl5.test-smoke.org/report/58805 Those warnings come from these files: ##### The patch attached silences the 'warning: this statement may fall The following warning remains during a gcc-7.2 build: ##### I don't yet know how to address that one. Please review the patch. Thank you very much. |
From @jkeenan0001-Prevent-warnings-when-building-with-gcc-7.2.patchFrom 915d1758bac3d1a7e1b7ec6c570ef70fce99d279 Mon Sep 17 00:00:00 2001
From: James E Keenan <[email protected]>
Date: Sat, 21 Oct 2017 21:27:18 -0400
Subject: [PATCH] Prevent warnings when building with gcc-7.2.
Guard against: "warning: this statement may fall through" warnings.
---
stadtx_hash.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/stadtx_hash.h b/stadtx_hash.h
index a54af2e..3b5dfb6 100644
--- a/stadtx_hash.h
+++ b/stadtx_hash.h
@@ -198,29 +198,39 @@ STADTX_STATIC_INLINE U64 stadtx_hash_with_state(
v0= ROTR64(v0, 17) ^ v1;
v1= ROTR64(v1, 53) + v0;
key += 8;
+ /* FALLTHROUGH */
case 2:
v0 += U8TO64_LE(key) * STADTX_K3_U64;
v0= ROTR64(v0, 17) ^ v1;
v1= ROTR64(v1, 53) + v0;
key += 8;
+ /* FALLTHROUGH */
case 1:
v0 += U8TO64_LE(key) * STADTX_K3_U64;
v0= ROTR64(v0, 17) ^ v1;
v1= ROTR64(v1, 53) + v0;
key += 8;
+ /* FALLTHROUGH */
case 0:
default: break;
}
switch ( len & 0x7 ) {
case 7: v0 += (U64)key[6] << 32;
+ /* FALLTHROUGH */
case 6: v1 += (U64)key[5] << 48;
+ /* FALLTHROUGH */
case 5: v0 += (U64)key[4] << 16;
+ /* FALLTHROUGH */
case 4: v1 += (U64)U8TO32_LE(key);
break;
+ /* FALLTHROUGH */
case 3: v0 += (U64)key[2] << 48;
+ /* FALLTHROUGH */
case 2: v1 += (U64)U8TO16_LE(key);
break;
+ /* FALLTHROUGH */
case 1: v0 += (U64)key[0];
+ /* FALLTHROUGH */
case 0: v1 = ROTL64(v1, 32) ^ 0xFF;
break;
}
@@ -253,25 +263,37 @@ STADTX_STATIC_INLINE U64 stadtx_hash_with_state(
switch ( len >> 3 ) {
case 3: v0 += ((U64)U8TO64_LE(key) * STADTX_K2_U32); key += 8; v0= ROTL64(v0,57) ^ v3;
+ /* FALLTHROUGH */
case 2: v1 += ((U64)U8TO64_LE(key) * STADTX_K3_U32); key += 8; v1= ROTL64(v1,63) ^ v2;
+ /* FALLTHROUGH */
case 1: v2 += ((U64)U8TO64_LE(key) * STADTX_K4_U32); key += 8; v2= ROTR64(v2,47) + v0;
+ /* FALLTHROUGH */
case 0: v3 = ROTR64(v3,11) - v1;
+ /* FALLTHROUGH */
}
v0 ^= (len+1) * STADTX_K3_U64;
switch ( len & 0x7 ) {
case 7: v1 += (U64)key[6];
+ /* FALLTHROUGH */
case 6: v2 += (U64)U8TO16_LE(key+4);
v3 += (U64)U8TO32_LE(key);
break;
+ /* FALLTHROUGH */
case 5: v1 += (U64)key[4];
+ /* FALLTHROUGH */
case 4: v2 += (U64)U8TO32_LE(key);
break;
+ /* FALLTHROUGH */
case 3: v3 += (U64)key[2];
+ /* FALLTHROUGH */
case 2: v1 += (U64)U8TO16_LE(key);
break;
+ /* FALLTHROUGH */
case 1: v2 += (U64)key[0];
+ /* FALLTHROUGH */
case 0: v3 = ROTL64(v3, 32) ^ 0xFF;
break;
+ /* FALLTHROUGH */
}
v1 -= v2;
--
2.7.4
|
From @jkeenanSummary of my perl5 (revision 5 version 27 subversion 6) configuration: Characteristics of this binary (from libperl): |
From @jkeenanOn Sun, 22 Oct 2017 02:25:29 GMT, jkeenan@pobox.com wrote:
Code review by mauke++ on #p5p indicated that some of my FALLTHROUGH guards were superfluous. Providing supplementary patch. Please review. Thank you very much. |
From @jkeenan0002-Remove-superfluous-FALLTHROUGH-guards.patchFrom 4fd1c57d681355f0e0bb51ead65c9552fbaf325a Mon Sep 17 00:00:00 2001
From: James E Keenan <[email protected]>
Date: Sun, 22 Oct 2017 07:48:43 -0400
Subject: [PATCH 2/2] Remove superfluous FALLTHROUGH guards.
Per code review by mauke++ on #p5p.
---
stadtx_hash.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/stadtx_hash.h b/stadtx_hash.h
index 3b5dfb6..c755018 100644
--- a/stadtx_hash.h
+++ b/stadtx_hash.h
@@ -223,12 +223,10 @@ STADTX_STATIC_INLINE U64 stadtx_hash_with_state(
/* FALLTHROUGH */
case 4: v1 += (U64)U8TO32_LE(key);
break;
- /* FALLTHROUGH */
case 3: v0 += (U64)key[2] << 48;
/* FALLTHROUGH */
case 2: v1 += (U64)U8TO16_LE(key);
break;
- /* FALLTHROUGH */
case 1: v0 += (U64)key[0];
/* FALLTHROUGH */
case 0: v1 = ROTL64(v1, 32) ^ 0xFF;
@@ -278,22 +276,18 @@ STADTX_STATIC_INLINE U64 stadtx_hash_with_state(
case 6: v2 += (U64)U8TO16_LE(key+4);
v3 += (U64)U8TO32_LE(key);
break;
- /* FALLTHROUGH */
case 5: v1 += (U64)key[4];
/* FALLTHROUGH */
case 4: v2 += (U64)U8TO32_LE(key);
break;
- /* FALLTHROUGH */
case 3: v3 += (U64)key[2];
/* FALLTHROUGH */
case 2: v1 += (U64)U8TO16_LE(key);
break;
- /* FALLTHROUGH */
case 1: v2 += (U64)key[0];
/* FALLTHROUGH */
case 0: v3 = ROTL64(v3, 32) ^ 0xFF;
break;
- /* FALLTHROUGH */
}
v1 -= v2;
--
2.7.4
|
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Sun, 22 Oct 2017 12:08:01 GMT, jkeenan wrote:
Patches were applied to blead in commit b2733f8 and 6437ba6. Most of the implicit-fallthrough warnings are gone. However, when I subsequently built with gcc-7 on a *threaded build*, there were still some of those warnings: ##### Needs further investigation. Thank you very much. |
From @maukeOn Sun, 22 Oct 2017 06:32:38 -0700, jkeenan wrote:
I believe the fallthrough warning is fixed in commit 146930d. |
From @jkeenanOn Sun, 22 Oct 2017 14:21:58 GMT, mauke- wrote:
Yes -- but unfortunately I just spotted this: ##### -- |
From @jkeenanOn Sun, 22 Oct 2017 14:57:00 GMT, jkeenan wrote:
And mauke++ has taken care of this one as well: ##### get rid of "implicit fallthrough" warnings with gcc 7 I think we've now eliminated this warning from non-threaded and threaded builds on Linux with gcc-7 -- at least from those files that are p5p-maintained. I will prepare patches for files that are cpan-upstream, but we don't need to keep this ticket open for that. Marking ticket Resolved. Thank you very much. |
@jkeenan - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#132342 (status was 'resolved')
Searchable as RT132342$
The text was updated successfully, but these errors were encountered: