home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Turbo C++, function prototypes
- Message-ID: <1992Sep3.173446.14427@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Aug31.181755.13060@hou.amoco.com> <2262@bigfoot.first.gmd.de> <1992Sep1.160816.10309@lclark.edu> <1992Sep2.162728.11201@taumet.com> <9224705.23705@mulga.cs.mu.OZ.AU>
- Date: Thu, 3 Sep 1992 17:34:46 GMT
- Lines: 34
-
- fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
-
- >steve@taumet.com (Steve Clamage) writes:
-
- >>If you write, for example,
- >> void main(){ }
- >>The compiler is obligated to diagnose an error in C and C++.
-
- >Are you sure? I've just tested three supposably ANSI-compliant C compilers
- >and NONE of them diagnose an error (or even a warning!).
-
- >I also tested three C++ compilers, and got one error and one warning.
-
- I have to retreat from my earlier position. The ANSI C standard
- requirement (2.1.2.2.1 and 2.1.2.2.3) is not in a "constraint" section,
- so a diagnostic is not strictly required. The result of defining
- main() with a return type of void is therefore undefined -- an
- "unconstrained error".
-
- Many unconstrained errors are very difficult or even impossible to
- detect, which is why the Standard differentiates them from
- constraint violations. The return type of main() is always detected!
-
- A compiler may diagnose unconstrained errors, and I would expect a
- compiler to diagnose this one, if only in "strict" mode. (A
- "warning" is a diagnostic, for example.)
-
- For C++, the ARM does not address required diagnostics. It does say
- that main() returns a value to the environment; this would exclude a
- definition with return type void.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-