Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: what is the output |
| Date | 2011-07-04 17:10 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <kfnbox937v5.fsf@x-alumni2.alumni.caltech.edu> (permalink) |
| References | <fde0c807-8924-4328-887b-42495fcc80c5@d26g2000prn.googlegroups.com> <iuqa1r$soe$1@dont-email.me> <kfn4o324ytf.fsf@x-alumni2.alumni.caltech.edu> <iur6ot$83h$1@dont-email.me> |
Eric Sosman <esosman@ieee-dot-org.invalid> writes:
> On 7/3/2011 9:30 PM, Tim Rentsch wrote:
>> Eric Sosman<esosman@ieee-dot-org.invalid> writes:
>>
>>> On 7/3/2011 12:32 PM, vinay kumar wrote:
>>>> main()
>>>> {
>>>> int d=010;
>>>> printf("%d",d);
>>>> }
>>>>
>>>> please give with explanation
>>> [snip]
>>>
>>> Also either (1) "semi-undefined" because a C90 int-valued
>>> function returns without returning a value, [snip]
>>
>> Actually this aspect's behavior is defined; only the termination
>> status returned to the host environment is undefined. (Or it is
>> implementation-defined in a freestanding implementation.)
>
> To the first point, that's what I intended to indicate with the
> weasel-words "semi-defined." The behavior is undefined if (1) the
> caller of main() is written in C, and (2) the caller makes use of the
> returned value. If the returned value is not used, there's no problem.
> And if the caller is not written in C, then C's rules don't apply.
Reading this reminds me of a quote: "I concede your point -
if things were different, they wouldn't be the same."
Yes, _if_ it were true that what we're looking at is only
part of a program rather than the whole program then these
considerations might come into play. For all we know this
piece comes after an #if 0 ...
However, most who commented on it, including yourself,
responded as though what's presented is an entire program.
In that context, C90 specifically and explicitly defines the
behavior of returning from main() without giving a return
value to say the termination status returned to the host
environment is undefined. Anything beyond that is simply
outside the scope of the C standard, as is true for all
terminations. You might as well say that 'return 0;' from
main() is "semi-defined"; in neither case is there anything
more to say about what happens further, as whatever that may
be is outside the realm of both language and implementation.
> To the second point, in a free-standing implementation it is not
> possible to predict (from the information given) what output, if any,
> is produced. For all we know, printf() computes checksums of its
> arguments, combines them into a complex number, and returns the
> logarithm thereof after launching the nuclear missiles.
Sorry, I thought it was clear from how the snipping was done
that I was addressing only the one aspect of the program
that the sentence being responded to concerns itself with,
namely, the behavor of returning without using a 'return'
statement.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
what is the output vinay kumar <vinay5b9@gmail.com> - 2011-07-03 09:32 -0700
Re: what is the output "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2011-07-03 19:43 +0200
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-03 13:47 -0400
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-03 12:15 -0700
Re: what is the output Chad <cdalten@gmail.com> - 2011-07-03 13:55 -0700
Re: what is the output "osmium" <r124c4u102@comcast.net> - 2011-07-03 16:20 -0500
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-03 14:24 -0700
Re: what is the output Chad <cdalten@gmail.com> - 2011-07-03 16:13 -0700
Re: what is the output "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-07-03 21:10 -0400
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-04 14:22 -0700
Re: what is the output Todd Carnes <toddcarnes@gmail.com> - 2011-07-05 03:30 +0000
Re: what is the output John Gordon <gordon@panix.com> - 2011-07-05 02:26 +0000
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 18:30 -0700
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-03 21:58 -0400
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-04 17:10 -0700
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-04 21:42 -0400
Re: what is the output Shao Miller <sha0.miller@gmail.com> - 2011-07-04 22:51 -0400
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-06 16:23 -0700
Re: what is the output Michael Press <rubrum@pacbell.net> - 2011-07-03 21:23 -0700
Re: what is the output Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-03 14:06 -0600
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 18:19 -0700
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-03 22:12 -0400
Re: what is the output Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-03 21:16 -0600
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-04 13:59 -0700
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-04 17:15 -0700
Re: what is the output Martin Ambuhl <mambuhl@earthlink.net> - 2011-07-04 17:21 -0400
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-04 17:27 -0700
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-04 18:07 -0700
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-06 17:08 -0700
Re: what is the output "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-07-04 22:19 -0400
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-04 23:19 -0400
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-05 08:34 -0700
Re: what is the output Shao Miller <sha0.miller@gmail.com> - 2011-07-04 18:26 -0400
Re: what is the output Todd Carnes <toddcarnes@gmail.com> - 2011-07-05 03:36 +0000
csiph-web