From 4408819292087242410
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,22698cf43904ecac
X-Google-Attributes: gidf78e5,public
From: miker3@ix.netcom.com (Mike Rubenstein)
Subject: Re: iostream changes
Date: 1997/09/15
Message-ID: <341bad43.42589159@nntp.ix.netcom.com>#1/1
X-Deja-AN: 272805059
References: <340BA7EE.500A@parawave.com> <5v6ife$64h@hermes.synopsys.com> <34173136.52AA@Eng.Sun.COM> <EGDHsv.60w@research.att.com> <341c2ac9.169360657@nntp.ix.netcom.com> <5vc9mk$9f8$3@news.belwue.de>
X-Original-Date: Sat, 13 Sep 1997 15:59:57 GMT
Organization: Netcom
X-NETCOM-Date: Sat Sep 13 10:59:59 AM CDT 1997
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBNB3c/Ey4NqrwXLNJAQGyHQH+NKI9/dzaWX5FwpP0fhktacsM5IE9MwAc YorIXiN38EK39U5SvsFAn3FB5dEa9C6qstN2yTgGWrPU4DNA0vBgSQ== =bQxn
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


kuehl@horn.informatik.uni-konstanz.de (Dietmar Kuehl) wrote:

> Hi,
> Mike Rubenstein (miker3@ix.netcom.com) wrote:
> : bs@research.att.com (Bjarne Stroustrup) wrote:
> : > 	#include<iostream>
> : > 
> : > 	int main()
> : > 	{
> : > 		std::cout << "Hello, world\n";
> : > 	}
> 
> : the example you give.  Even there, it gives a warning and it is
> : questionable whether the program produced executes as required by the
> : standard (it returns a nonzero return code to the command processor
> : instead of 0 which is normally used for successful execution under
> : Windows NT).
> 
> Just note, that the program posted by Bjarne Stroustrup is standard
> conformant *AND* returns EXIT_SUCCESS (which is defined to be 0). That
> is, it is completely correct. According to the standard, that is... The
> point here is the special exception for the function 'main()' saying
> that floating off the end of the function 'main()' is equivalent to
> exiting the function with 'return 0;'.  However, this is a special
> exception holding only for 'main()'. Floating off the end of any other
> function returning something different than 'void' resutls in undefined
> behavior.

Generally correct, but one nit to pick:  EXIT_SUCCESS is not
necessarily defined to be 0.  return from main or exit with either
EXIT_SUCCESS or 0 returns an implementation-defined status indicating
successful termination, but they are not required to be identical (and
there may be other values that can be returned to indicate successful
termination).  The draft says nothing about whether different values
used for successful termination are distinguishable.

My point in saying it was questionable whether Microsoft complies with
the standard was based on the fact that there is no requirement that 0
actually be returned to the host environment if main returns 0.  In
fact, there are systems in which that should not be done since 0
normally means unsuccessful termination; on such systems the run time
must change the returned value to something appropriate.

The implementor is free to define anything he likes as "successful
termination."  However, it's obvious that the intent is that it be
defined in a way that is consistent with the usual operating system
conventions, which on Windows NT means that 0, and only 0, indicates
successful termination.

The implementation's definition of "successful implementation" is
really a quality of implementation issue -- a Windows NT
implementation that defines it as anything but returning 0 is poor in
that regard.

Implementation-defined behavior must be documented.  I can find
nothing on successful termination in Microsoft's section on
implementation-defined behavior, but the documentation for exit
clearly indicates that the argument (or the returned value from main)
is actually returned to the operating system and seems to say that 0
is the only value for successful termination.

I'd say that given Microsoft's documentation, the translation of the
program does not comply with the standard, but someone who is kinder
might say that it does but is very poorly implemented; I can't think
of anything kinder one might say.

Michael M Rubenstein
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



