Skip to content
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

Many implicit-fallthrough errors #7295

Closed
yelkarama opened this issue Jun 24, 2021 · 12 comments
Closed

Many implicit-fallthrough errors #7295

yelkarama opened this issue Jun 24, 2021 · 12 comments
Labels

Comments

@yelkarama
Copy link

yelkarama commented Jun 24, 2021

I did this

Building the latest release of curl (7.77) on RHEL6 using newly built gcc toolchain (git: 12.0.0)
When using Werror, I'm getting these many implicit-fallthrough error:

>[21/206] Building C object lib/CMakeFiles/libcurl.dir/content_encoding.c.o
FAILED: lib/CMakeFiles/libcurl.dir/content_encoding.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/content_encoding.c.o -MF lib/CMakeFiles/libcurl.dir/content_encoding.c.o.d -o lib/CMakeFiles/libcurl.dir/content_encoding.c.o -c ../lib/content_encoding.c
../lib/content_encoding.c: In function 'inflate_stream':
../lib/content_encoding.c:230:9: error: this statement may fall through [-Werror=implicit-fallthrough=]
  230 |       if(zp->zlib_init == ZLIB_INIT) {
      |         ^
../lib/content_encoding.c:244:5: note: here
  244 |     default:
      |     ^~~~~~~
cc1: all warnings being treated as errors
[23/206] Building C object lib/CMakeFiles/libcurl.dir/cookie.c.o
FAILED: lib/CMakeFiles/libcurl.dir/cookie.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/cookie.c.o -MF lib/CMakeFiles/libcurl.dir/cookie.c.o.d -o lib/CMakeFiles/libcurl.dir/cookie.c.o -c ../lib/cookie.c
../lib/cookie.c: In function 'Curl_cookie_add':
../lib/cookie.c:899:15: error: this statement may fall through [-Werror=implicit-fallthrough=]
  899 |         fields++; /* add a field and fall down to secure */
      |         ~~~~~~^~
../lib/cookie.c:901:7: note: here
  901 |       case 3:
      |       ^~~~
cc1: all warnings being treated as errors
[45/206] Building C object lib/CMakeFiles/libcurl.dir/ftp.c.o
FAILED: lib/CMakeFiles/libcurl.dir/ftp.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/ftp.c.o -MF lib/CMakeFiles/libcurl.dir/ftp.c.o.d -o lib/CMakeFiles/libcurl.dir/ftp.c.o -c ../lib/ftp.c
../lib/ftp.c: In function 'ftp_done':
../lib/ftp.c:3216:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
 3216 |     if(!premature)
      |       ^
../lib/ftp.c:3222:3: note: here
 3222 |   default:       /* by default, an error means the control connection is
      |   ^~~~~~~
cc1: all warnings being treated as errors
[57/206] Building C object lib/CMakeFiles/libcurl.dir/formdata.c.o
FAILED: lib/CMakeFiles/libcurl.dir/formdata.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/formdata.c.o -MF lib/CMakeFiles/libcurl.dir/formdata.c.o.d -o lib/CMakeFiles/libcurl.dir/formdata.c.o -c ../lib/formdata.c
../lib/formdata.c: In function 'FormAdd':
../lib/formdata.c:278:27: error: this statement may fall through [-Werror=implicit-fallthrough=]
  278 |       current_form->flags |= HTTPPOST_PTRNAME; /* fall through */
      |       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
../lib/formdata.c:281:5: note: here
  281 |     case CURLFORM_COPYNAME:
      |     ^~~~
../lib/formdata.c:305:27: error: this statement may fall through [-Werror=implicit-fallthrough=]
  305 |       current_form->flags |= HTTPPOST_PTRCONTENTS;
      |       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
../lib/formdata.c:307:5: note: here
  307 |     case CURLFORM_COPYCONTENTS:
      |     ^~~~
cc1: all warnings being treated as errors
[61/206] Building C object lib/CMakeFiles/libcurl.dir/http_ntlm.c.o
FAILED: lib/CMakeFiles/libcurl.dir/http_ntlm.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/http_ntlm.c.o -MF lib/CMakeFiles/libcurl.dir/http_ntlm.c.o.d -o lib/CMakeFiles/libcurl.dir/http_ntlm.c.o -c ../lib/http_ntlm.c
../lib/http_ntlm.c: In function 'Curl_output_ntlm':
../lib/http_ntlm.c:252:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
  252 |     *state = NTLMSTATE_LAST;
      |     ~~~~~~~^~~~~~~~~~~~~~~~
../lib/http_ntlm.c:254:3: note: here
  254 |   case NTLMSTATE_LAST:
      |   ^~~~
cc1: all warnings being treated as errors
[73/206] Building C object lib/CMakeFiles/libcurl.dir/http.c.o
FAILED: lib/CMakeFiles/libcurl.dir/http.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/http.c.o -MF lib/CMakeFiles/libcurl.dir/http.c.o.d -o lib/CMakeFiles/libcurl.dir/http.c.o -c ../lib/http.c
../lib/http.c: In function 'Curl_http_statusline':
../lib/http.c:3746:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
 3746 |     if(data->set.timecondition)
      |       ^
../lib/http.c:3749:3: note: here
 3749 |   case 204:
      |   ^~~~
cc1: all warnings being treated as errors
[77/206] Building C object lib/CMakeFiles/libcurl.dir/mqtt.c.o
FAILED: lib/CMakeFiles/libcurl.dir/mqtt.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/mqtt.c.o -MF lib/CMakeFiles/libcurl.dir/mqtt.c.o.d -o lib/CMakeFiles/libcurl.dir/mqtt.c.o -c ../lib/mqtt.c
../lib/mqtt.c: In function 'mqtt_doing':
../lib/mqtt.c:575:5: error: this statement may fall through [-Werror=implicit-fallthrough=]
  575 |     mqstate(data, MQTT_REMAINING_LENGTH, MQTT_NOSTATE);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/mqtt.c:577:3: note: here
  577 |   case MQTT_REMAINING_LENGTH:
      |   ^~~~
../lib/mqtt.c: In function 'mqtt_read_publish':
../lib/mqtt.c:483:17: error: this statement may fall through [-Werror=implicit-fallthrough=]
  483 |     mq->npacket = remlen; /* get this many bytes */
      |     ~~~~~~~~~~~~^~~~~~~~
../lib/mqtt.c:485:3: note: here
  485 |   case MQTT_PUB_REMAIN: {
      |   ^~~~
cc1: all warnings being treated as errors
[82/206] Building C object lib/CMakeFiles/libcurl.dir/multi.c.o
FAILED: lib/CMakeFiles/libcurl.dir/multi.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/multi.c.o -MF lib/CMakeFiles/libcurl.dir/multi.c.o.d -o lib/CMakeFiles/libcurl.dir/multi.c.o -c ../lib/multi.c
../lib/multi.c: In function 'Curl_update_timer':
../lib/multi.c:3199:64: error: '?:' using integer constants in boolean context [-Werror=int-in-bool-context]
 3199 |     if(Curl_splaycomparekeys(none, multi->timer_lastcall)) {
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ^                                                                                                                                                                                      
cc1: all warnings being treated as errors
[90/206] Building C object lib/CMakeFiles/libcurl.dir/mprintf.c.o
FAILED: lib/CMakeFiles/libcurl.dir/mprintf.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/mprintf.c.o -MF lib/CMakeFiles/libcurl.dir/mprintf.c.o.d -o lib/CMakeFiles/libcurl.dir/mprintf.c.o -c ../lib/mprintf.c
../lib/mprintf.c: In function 'dprintf_Pass1':
../lib/mprintf.c:362:13: error: this statement may fall through [-Werror=implicit-fallthrough=]
  362 |           if(!(flags & FLAGS_LEFT))
      |             ^
../lib/mprintf.c:365:9: note: here
  365 |         case '1': case '2': case '3': case '4':
      |         ^~~~
../lib/mprintf.c:399:15: error: this statement may fall through [-Werror=implicit-fallthrough=]
  399 |         flags |= FLAGS_ALT;
      |         ~~~~~~^~~~~~~~~~~~
../lib/mprintf.c:401:7: note: here
  401 |       case 's':
      |       ^~~~
cc1: all warnings being treated as errors
[99/206] Building C object lib/CMakeFiles/libcurl.dir/socks.c.o
FAILED: lib/CMakeFiles/libcurl.dir/socks.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/socks.c.o -MF lib/CMakeFiles/libcurl.dir/socks.c.o.d -o lib/CMakeFiles/libcurl.dir/socks.c.o -c ../lib/socks.c
../lib/socks.c: In function 'Curl_SOCKS4':
../lib/socks.c:262:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
  262 |     if(dns) {
      |       ^
../lib/socks.c:279:3: note: here
  279 |   CONNECT_RESOLVED:
      |   ^~~~~~~~~~~~~~~~
../lib/socks.c:280:26: error: this statement may fall through [-Werror=implicit-fallthrough=]
  280 |   case CONNECT_RESOLVED: {
      |                          ^
../lib/socks.c:317:3: note: here
  317 |   CONNECT_REQ_INIT:
      |   ^~~~~~~~~~~~~~~~
../lib/socks.c:359:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
  359 |       sxstate(data, CONNECT_REQ_SENDING);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../lib/socks.c:362:3: note: here
  362 |   case CONNECT_REQ_SENDING:
      |   ^~~~
../lib/socks.c:380:5: error: this statement may fall through [-Werror=implicit-fallthrough=]
  380 |     sxstate(data, CONNECT_SOCKS_READ);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../lib/socks.c:383:3: note: here
  383 |   case CONNECT_SOCKS_READ:
      |   ^~~~
../lib/socks.c: In function 'Curl_SOCKS5':
../lib/socks.c:584:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
  584 |     if(written != sx->outstanding) {
      |       ^
../lib/socks.c:591:3: note: here
  591 |   CONNECT_SOCKS_READ_INIT:
      |   ^~~~~~~~~~~~~~~~~~~~~~~
../lib/socks.c:594:14: error: this statement may fall through [-Werror=implicit-fallthrough=]
  594 |     sx->outp = socksreq; /* store it here */
      |     ~~~~~~~~~^~~~~~~~~~
../lib/socks.c:596:3: note: here
  596 |   case CONNECT_SOCKS_READ:
      |   ^~~~
../lib/socks.c:706:14: error: this statement may fall through [-Werror=implicit-fallthrough=]
  706 |     sx->outp = socksreq;
      |     ~~~~~~~~~^~~~~~~~~~
../lib/socks.c:709:3: note: here
  709 |   case CONNECT_AUTH_SEND:
      |   ^~~~
../lib/socks.c:724:5: error: this statement may fall through [-Werror=implicit-fallthrough=]
  724 |     sxstate(data, CONNECT_AUTH_READ);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../lib/socks.c:726:3: note: here
  726 |   case CONNECT_AUTH_READ:
      |   ^~~~
../lib/socks.c:752:5: error: this statement may fall through [-Werror=implicit-fallthrough=]
  752 |     sxstate(data, CONNECT_REQ_INIT);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../lib/socks.c:754:3: note: here
  754 |   CONNECT_REQ_INIT:
      |   ^~~~~~~~~~~~~~~~
../lib/socks.c:784:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
  784 |     if(!dns) {
      |       ^
../lib/socks.c:793:3: note: here
  793 |   CONNECT_RESOLVED:
      |   ^~~~~~~~~~~~~~~~
../lib/socks.c:856:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
  856 |     if(!socks5_resolve_local) {
      |       ^
../lib/socks.c:866:3: note: here
  866 |   CONNECT_REQ_SEND:
      |   ^~~~~~~~~~~~~~~~
../lib/socks.c:881:5: error: this statement may fall through [-Werror=implicit-fallthrough=]
  881 |     sxstate(data, CONNECT_REQ_SENDING);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../lib/socks.c:883:3: note: here
  883 |   case CONNECT_REQ_SENDING:
      |   ^~~~
../lib/socks.c:904:5: error: this statement may fall through [-Werror=implicit-fallthrough=]
  904 |     sxstate(data, CONNECT_REQ_READ);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../lib/socks.c:906:3: note: here
  906 |   case CONNECT_REQ_READ:
      |   ^~~~
../lib/socks.c:992:9: error: this statement may fall through [-Werror=implicit-fallthrough=]
  992 |       if(len > 10) {
      |         ^
../lib/socks.c:1005:3: note: here
 1005 |   case CONNECT_REQ_READ_MORE:
      |   ^~~~
cc1: all warnings being treated as errors
[105/206] Building C object lib/CMakeFiles/libcurl.dir/mime.c.o
FAILED: lib/CMakeFiles/libcurl.dir/mime.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/mime.c.o -MF lib/CMakeFiles/libcurl.dir/mime.c.o.d -o lib/CMakeFiles/libcurl.dir/mime.c.o -c ../lib/mime.c
../lib/mime.c: In function 'encoder_base64_read':
../lib/mime.c:467:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
  467 |         i = (st->buf[st->bufbeg + 1] & 0xFF) << 8;
      |         ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/mime.c:469:7: note: here
  469 |       case 1:
      |       ^~~~
../lib/mime.c: In function 'readback_part':
../lib/mime.c:966:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
  966 |         if(part->kind == MIMEKIND_FILE && part->fp) {
      |           ^
../lib/mime.c:971:7: note: here
  971 |       case CURL_READFUNC_ABORT:
      |       ^~~~
../lib/mime.c:924:9: error: this statement may fall through [-Werror=implicit-fallthrough=]
  924 |       if(match_header(hdr, "Content-Type", 12)) {
      |         ^
../lib/mime.c:929:5: note: here
  929 |     case MIMESTATE_CURLHEADERS:
      |     ^~~~
../lib/mime.c: In function 'read_part_content':
../lib/mime.c:804:9: error: this statement may fall through [-Werror=implicit-fallthrough=]
  804 |       if(part->fp && feof(part->fp))
      |         ^
../lib/mime.c:807:5: note: here
  807 |     default:
      |     ^~~~~~~
cc1: all warnings being treated as errors
[114/206] Building C object lib/CMakeFiles/libcurl.dir/telnet.c.o
FAILED: lib/CMakeFiles/libcurl.dir/telnet.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/telnet.c.o -MF lib/CMakeFiles/libcurl.dir/telnet.c.o.d -o lib/CMakeFiles/libcurl.dir/telnet.c.o -c ../lib/telnet.c
../lib/telnet.c: In function 'telnet_do':
../lib/telnet.c:1495:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1495 |       pfd[1].revents = 0;
      |       ~~~~~~~~~~~~~~~^~~
../lib/telnet.c:1497:5: note: here
 1497 |     default:                    /* read! */
      |     ^~~~~~~
cc1: all warnings being treated as errors
[115/206] Building C object lib/CMakeFiles/libcurl.dir/urlapi.c.o
FAILED: lib/CMakeFiles/libcurl.dir/urlapi.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/urlapi.c.o -MF lib/CMakeFiles/libcurl.dir/urlapi.c.o.d -o lib/CMakeFiles/libcurl.dir/urlapi.c.o -c ../lib/urlapi.c
../lib/urlapi.c: In function 'strlen_url':
../lib/urlapi.c:162:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
  162 |       left = FALSE;
../lib/urlapi.c:164:5: note: here
  164 |     default:
      |     ^~~~~~~
../lib/urlapi.c: In function 'strcpy_url':
../lib/urlapi.c:207:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
  207 |       left = FALSE;
../lib/urlapi.c:209:5: note: here
  209 |     default:
      |     ^~~~~~~
cc1: all warnings being treated as errors
[152/206] Building C object lib/CMakeFiles/libcurl.dir/vtls/openssl.c.o
FAILED: lib/CMakeFiles/libcurl.dir/vtls/openssl.c.o 
/usr/lib/ccache/bin/gcc -DBUILDING_LIBCURL -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -I../include -Ilib/../include -I../lib/.. -I../lib/../include -Ilib/.. -I../lib -Ilib -isystem /var/data/gcc12gnu212/x86_64-linux-gnu/sysroot/usr/include -Ofast -s -fPIC -pipe -DNDEBUG -march=x86-64 -Wl,--strip-debug,--strip-all -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wno-long-long -Wno-multichar -Wno-format-nonliteral -Wno-sign-conversion -Wno-system-headers -Werror -O3 -DNDEBUG -fvisibility=hidden -MD -MT lib/CMakeFiles/libcurl.dir/vtls/openssl.c.o -MF lib/CMakeFiles/libcurl.dir/vtls/openssl.c.o.d -o lib/CMakeFiles/libcurl.dir/vtls/openssl.c.o -c ../lib/vtls/openssl.c
../lib/vtls/openssl.c: In function 'cert_stuff':
../lib/vtls/openssl.c:998:9: error: this statement may fall through [-Werror=implicit-fallthrough=]
  998 |       if(cert_done)
      |         ^
../lib/vtls/openssl.c:1001:5: note: here
 1001 |     case SSL_FILETYPE_ASN1:
      |     ^~~~
cc1: all warnings being treated as errors
[154/206] Building C object lib/CMakeFiles/libcurl.dir/url.c.o
ninja: build stopped: cannot make progress due to previous errors.

I expected the following

Successful build

curl/libcurl version

7.77

operating system

Linux localhost.localdomain 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

@dfandrich
Copy link
Contributor

dfandrich commented Jun 24, 2021 via email

@bagder
Copy link
Member

bagder commented Jun 24, 2021

Are not all of these places marked with /* FALLTHROUGH */ comments accordingly? I would argue that gcc should not complain when we have marked them like that.

@vszakats
Copy link
Member

vszakats commented Jun 25, 2021

Not long ago the /* FALLTHROUGH */-style tagging started to be replaced by different methods (e.g. __attribute__((__fallthrough__)) in gcc/llvm, and since then these newer releases also ignore this comment. I can't cite exact version numbers unfortunately.

Ref with some details: https://www.kernel.org/doc/html/v5.7/process/deprecated.html#implicit-switch-case-fall-through

@vszakats vszakats added the build label Jun 25, 2021
@bagder
Copy link
Member

bagder commented Jun 26, 2021

(What a weird behavior-breaking change.) So we'll need both the comment and a new creative way to define that attribute for the compilers that insist on that method...

@bagder
Copy link
Member

bagder commented Jun 27, 2021

@yelkarama, are you interested in working on a fix for this?

@jzakrzewski
Copy link
Contributor

I'd expect this (WIP) page to list such a breaking change. I also was unable to locate a commit that may introduce such change. Maybe it's some kind of bug in gcc (the gcc12 cycle has just begun)?

bagder added a commit that referenced this issue Jun 27, 2021
Make configure/cmake check if the attribute works, then use the
FALLTHROUGH define instead of the previous comment to inhibit compiler
warnings for when a switch-case doesn't end with a break or return.

Reported-by: Younes El-karama
Fixes #7295
@bagder
Copy link
Member

bagder commented Jun 27, 2021

I did a first take on using the attribute - in #7302

@vszakats
Copy link
Member

vszakats commented Jun 27, 2021

[ Looks like this feature first appeared in GCC 7 with support for the attribute and various flavours of comments, configurable via the -Wimplicit-fallthrough[=mode] option. LLVM later added support for the attribute first (~2019), then for comments (~2020). ]

@bagder
Copy link
Member

bagder commented Jun 28, 2021

Based on the results of my attempt to fix this, I think we might instead rather decide to stick with the comment version for the time being. There doesn't even seem to be a reliable way to silence these warnings using the attribute method in our CI, so I can't even start to fathom how spectacularly it'll fail at users' places if we'd decide to ship that.

@yelkarama I propose you tell your compiler to accept the comments as fallthrough-indicators.

bagder added a commit that referenced this issue Jun 28, 2021
... since it no longer acknowledges the comment markup we use for that
purpose.

Reported-by: Younes El-karama
Fixes #7295
@vszakats
Copy link
Member

@bagder: It indeed looks like a hot mess. Tried digging up info about the default warning mode in GCC, but the documentation wasn't helpful there. The LLVM doc is even less talkative and for some reason lists this option as far back as clang 4.0.0 (early 2017). The end result when doing an actual build is rather accidental. It's less than ideal because otherwise this warning (when justified) is useful.

@bagder
Copy link
Member

bagder commented Jun 28, 2021

The warning is indeed very useful, but fortunately we can probably still enjoy the warnings from pre gcc-12 compilers for a fairly long time ahead and hopefully things get fixed in 12 or later in the mean time!

@vszakats
Copy link
Member

@bagder Sounds good to me!

Meanwhile, if somebody has some definitive info/pointer on how to best deal with this issue, I guess we'd all love to learn about it.

@bagder bagder closed this as completed in b5a434f Jun 29, 2021
danielgustafsson added a commit to danielgustafsson/curl that referenced this issue Jun 30, 2021
Commit b5a434f inhibits the warning
on implicit fallthrough cases, since the current coding of indicating
fallthrough with comments is falling out of fashion with new compilers.
This attempts to make the issue smaller by rewriting fallthroughs to no
longer fallthrough, via either breaking the cases or turning switch
statements into if statements.

  lib/content_encoding.c: the fallthrough codepath is simply copied
    into the case as it's a single line.
  lib/http_ntlm.c: the fallthrough case skips a state in the state-
    machine and fast-forwards to NTLMSTATE_LAST. Do this before the
    switch statement instead to set up the states that we actually
    want.
  lib/http_proxy.c: the fallthrough is just falling into exiting the
    switch statement which can be done easily enough in the case.
  lib/mime.c: switch statement rewritten as if statement.
  lib/pop3.c: the fallthrough case skips to the next state in the
    statemachine, do this explicitly instead.
  lib/urlapi.c: switch statement rewritten as if statement.
  lib/vssh/wolfssh.c: the fallthrough cases fast-forwards the state
    machine, do this by running another iteration of the switch
    statement instead.
  lib/vtls/gtls.c: switch statement rewritten as if statement.
  lib/vtls/nss.c: the fallthrough codepath is simply copied into the
    case as it's a single line. Also twiddle a comment to not be
    inside a non-brace if statement.

Closes: #xxxx
See-also: curl#7295
danielgustafsson added a commit to danielgustafsson/curl that referenced this issue Jul 28, 2021
Commit b5a434f inhibits the warning
on implicit fallthrough cases, since the current coding of indicating
fallthrough with comments is falling out of fashion with new compilers.
This attempts to make the issue smaller by rewriting fallthroughs to no
longer fallthrough, via either breaking the cases or turning switch
statements into if statements.

  lib/content_encoding.c: the fallthrough codepath is simply copied
    into the case as it's a single line.
  lib/http_ntlm.c: the fallthrough case skips a state in the state-
    machine and fast-forwards to NTLMSTATE_LAST. Do this before the
    switch statement instead to set up the states that we actually
    want.
  lib/http_proxy.c: the fallthrough is just falling into exiting the
    switch statement which can be done easily enough in the case.
  lib/mime.c: switch statement rewritten as if statement.
  lib/pop3.c: the fallthrough case skips to the next state in the
    statemachine, do this explicitly instead.
  lib/urlapi.c: switch statement rewritten as if statement.
  lib/vssh/wolfssh.c: the fallthrough cases fast-forwards the state
    machine, do this by running another iteration of the switch
    statement instead.
  lib/vtls/gtls.c: switch statement rewritten as if statement.
  lib/vtls/nss.c: the fallthrough codepath is simply copied into the
    case as it's a single line. Also twiddle a comment to not be
    inside a non-brace if statement.

Closes: #xxxx
See-also: curl#7295
danielgustafsson added a commit to danielgustafsson/curl that referenced this issue Sep 28, 2021
Commit b5a434f inhibits the warning
on implicit fallthrough cases, since the current coding of indicating
fallthrough with comments is falling out of fashion with new compilers.
This attempts to make the issue smaller by rewriting fallthroughs to no
longer fallthrough, via either breaking the cases or turning switch
statements into if statements.

  lib/content_encoding.c: the fallthrough codepath is simply copied
    into the case as it's a single line.
  lib/http_ntlm.c: the fallthrough case skips a state in the state-
    machine and fast-forwards to NTLMSTATE_LAST. Do this before the
    switch statement instead to set up the states that we actually
    want.
  lib/http_proxy.c: the fallthrough is just falling into exiting the
    switch statement which can be done easily enough in the case.
  lib/mime.c: switch statement rewritten as if statement.
  lib/pop3.c: the fallthrough case skips to the next state in the
    statemachine, do this explicitly instead.
  lib/urlapi.c: switch statement rewritten as if statement.
  lib/vssh/wolfssh.c: the fallthrough cases fast-forwards the state
    machine, do this by running another iteration of the switch
    statement instead.
  lib/vtls/gtls.c: switch statement rewritten as if statement.
  lib/vtls/nss.c: the fallthrough codepath is simply copied into the
    case as it's a single line. Also twiddle a comment to not be
    inside a non-brace if statement.

Closes: #xxxx
See-also: curl#7295
danielgustafsson added a commit that referenced this issue Sep 29, 2021
Commit b5a434f inhibits the warning
on implicit fallthrough cases, since the current coding of indicating
fallthrough with comments is falling out of fashion with new compilers.
This attempts to make the issue smaller by rewriting fallthroughs to no
longer fallthrough, via either breaking the cases or turning switch
statements into if statements.

  lib/content_encoding.c: the fallthrough codepath is simply copied
    into the case as it's a single line.
  lib/http_ntlm.c: the fallthrough case skips a state in the state-
    machine and fast-forwards to NTLMSTATE_LAST. Do this before the
    switch statement instead to set up the states that we actually
    want.
  lib/http_proxy.c: the fallthrough is just falling into exiting the
    switch statement which can be done easily enough in the case.
  lib/mime.c: switch statement rewritten as if statement.
  lib/pop3.c: the fallthrough case skips to the next state in the
    statemachine, do this explicitly instead.
  lib/urlapi.c: switch statement rewritten as if statement.
  lib/vssh/wolfssh.c: the fallthrough cases fast-forwards the state
    machine, do this by running another iteration of the switch
    statement instead.
  lib/vtls/gtls.c: switch statement rewritten as if statement.
  lib/vtls/nss.c: the fallthrough codepath is simply copied into the
    case as it's a single line. Also twiddle a comment to not be
    inside a non-brace if statement.

Closes: #7322
See-also: #7295
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 participants