Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #151805
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: This statement may fall through - how? |
| Date | 2020-04-29 18:37 -0700 |
| Organization | None to speak of |
| Message-ID | <87a72t7nzw.fsf@nosuchdomain.example.com> (permalink) |
| References | <r8d5h9$qe1$1@dont-email.me> <UNpqG.167200$2U3.5095@fx04.iad> |
scott@slp53.sl.home (Scott Lurndal) writes:
> mathog <mathog@caltech.edu> writes:
>>The code snippet below my signature generates this message when compiled:
>>
>>g++ -DHAVE_CONFIG_H -I. -I../..
>>-I/usr/common/modules/el8/x86_64/software/libgtextutils/0.7-CentOS-vanilla/include/gtextutils
>> -I../../src/libfastx -g -O2 -Wall -Wextra -Wformat-nonliteral
>>-Wformat-security -Wswitch-default -Wswitch-enum -Wunused-parameter
>>-Wfloat-equal -Werror -DDEBUG -g -O1 -MT fasta_formatter.o -MD -MP -MF
>>.deps/fasta_formatter.Tpo -c -o fasta_formatter.o fasta_formatter.cpp
>>fasta_formatter.cpp: In function ‘void parse_command_line(int, char**)’:
>>fasta_formatter.cpp:105:9: error: this statement may fall through
>>[-Werror=implicit-fallthrough=]
>> usage();
>> ~~~~~^~
>>fasta_formatter.cpp:107:3: note: here
>> case 'i':
>> ^~~~
>>
>>This is with gcc 8.3.1. Is there really some way that usage() can avoid
>>hitting exit() or is the compiler just emitting a general warning
>>without actually looking at usage()?
>
> Even if it did, it's possible for the programmer to
> provide his own 'exit()' function in a different compilation
> unit. The compiler can't assume that just because usage()
> called 'exit', it actually terminates the process.
Yes, the compiler can assume that.
N1570 7.1.3p1:
All identifiers with external linkage in any of the following
subclauses (including the future library directions) and errno are
always reserved for use as identifiers with external linkage.
Defining your own function named "exit" with external linkage has
undefined behavior.
Of course a compiler isn't *required* to assume that (the language
doesn't require it to dig into the implementation of the usage()
function to determine that it can never return).
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
This statement may fall through - how? mathog <mathog@caltech.edu> - 2020-04-29 17:18 -0700
Re: This statement may fall through - how? Ian Collins <ian-news@hotmail.com> - 2020-04-30 12:32 +1200
Re: This statement may fall through - how? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-04-29 18:03 -0700
Re: This statement may fall through - how? Ian Collins <ian-news@hotmail.com> - 2020-04-30 14:01 +1200
Re: This statement may fall through - how? mathog <mathog@caltech.edu> - 2020-04-30 13:29 -0700
Re: This statement may fall through - how? Spiros Bousbouras <spibou@gmail.com> - 2020-04-30 21:09 +0000
Re: This statement may fall through - how? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-04-30 15:19 -0700
Re: This statement may fall through - how? mathog <mathog@caltech.edu> - 2020-04-30 16:21 -0700
Re: This statement may fall through - how? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-04-30 17:27 -0700
Re: This statement may fall through - how? Ian Collins <ian-news@hotmail.com> - 2020-05-01 12:44 +1200
Re: This statement may fall through - how? mathog <mathog@caltech.edu> - 2020-05-01 10:28 -0700
Re: This statement may fall through - how? chad <cdalten@gmail.com> - 2020-05-01 12:43 -0700
Re: This statement may fall through - how? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-04-29 17:58 -0700
Re: This statement may fall through - how? scott@slp53.sl.home (Scott Lurndal) - 2020-04-30 01:25 +0000
Re: This statement may fall through - how? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-04-29 18:37 -0700
Re: This statement may fall through - how? Bonita Montero <Bonita.Montero@gmail.com> - 2020-04-30 10:33 +0200
Re: This statement may fall through - how? gazelle@shell.xmission.com (Kenny McCormack) - 2020-04-30 08:48 +0000
Re: This statement may fall through - how? Bonita Montero <Bonita.Montero@gmail.com> - 2020-04-30 10:54 +0200
Re: This statement may fall through - how? James Harris <james.harris.1@gmail.com> - 2020-04-30 10:03 +0100
Re: This statement may fall through - how? Bonita Montero <Bonita.Montero@gmail.com> - 2020-04-30 11:08 +0200
Re: This statement may fall through - how? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-04-30 02:15 -0700
Re: This statement may fall through - how? James Harris <james.harris.1@gmail.com> - 2020-04-30 12:27 +0100
Re: This statement may fall through - how? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-04-30 13:42 +0100
Re: This statement may fall through - how? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-04-30 10:26 -0400
Re: This statement may fall through - how? James Harris <james.harris.1@gmail.com> - 2020-04-30 17:43 +0100
Re: This statement may fall through - how? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-04-30 13:01 -0400
Re: This statement may fall through - how? Spiros Bousbouras <spibou@gmail.com> - 2020-04-30 17:34 +0000
Re: This statement may fall through - how? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-04-30 13:53 -0400
Re: This statement may fall through - how? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-04-30 13:21 -0700
Re: This statement may fall through - how? scott@slp53.sl.home (Scott Lurndal) - 2020-04-30 17:54 +0000
Re: This statement may fall through - how? chad <cdalten@gmail.com> - 2020-04-30 10:55 -0700
Re: This statement may fall through - how? Richard Damon <Richard@Damon-Family.org> - 2020-04-30 10:30 -0400
Re: This statement may fall through - how? gazelle@shell.xmission.com (Kenny McCormack) - 2020-04-30 09:10 +0000
Re: This statement may fall through - how? Bonita Montero <Bonita.Montero@gmail.com> - 2020-04-30 11:18 +0200
Re: This statement may fall through - how? mathog <mathog@caltech.edu> - 2020-04-30 13:13 -0700
csiph-web