Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Does this program have well-defined behaviour? |
| Date | 2012-08-12 16:42 -0700 |
| Organization | None to speak of |
| Message-ID | <ln4no7u180.fsf@nuthaus.mib.org> (permalink) |
| References | <a232a652-7ac4-47ce-96c9-f08dd619c43f@t7g2000vbe.googlegroups.com> |
eq mail <eq.mail.id@gmail.com> writes:
> Does the following have well-defined behaviour?
>
> #include <stdlib.h>
>
> int e(void)
> {
> exit(0);
> }
>
> int main(void)
> {
> return e();
> }
I believe so.
N1570 6.9.1p12:
If the } that terminates a function is reached, and the value of the
function call is used by the caller, the behavior is undefined.
Execution never reaches the closing } of the function "e".
That by itself doesn't prove that the behavior is well-defined, but I
think that everything the program does during execution has well-defined
behavior.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Does this program have well-defined behaviour? eq mail <eq.mail.id@gmail.com> - 2012-08-12 15:51 -0700 Re: Does this program have well-defined behaviour? Keith Thompson <kst-u@mib.org> - 2012-08-12 16:42 -0700 Re: Does this program have well-defined behaviour? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-12 21:05 -0400
csiph-web