home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13261 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.8 KB  |  45 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Turbo C++, function prototypes
  5. Message-ID: <1992Sep3.173446.14427@taumet.com>
  6. Organization: TauMetric Corporation
  7. 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>
  8. Date: Thu, 3 Sep 1992 17:34:46 GMT
  9. Lines: 34
  10.  
  11. fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  12.  
  13. >steve@taumet.com (Steve Clamage) writes:
  14.  
  15. >>If you write, for example,
  16. >>    void main(){ }
  17. >>The compiler is obligated to diagnose an error in C and C++.
  18.  
  19. >Are you sure? I've just tested three supposably ANSI-compliant C compilers
  20. >and NONE of them diagnose an error (or even a warning!). 
  21.  
  22. >I also tested three C++ compilers, and got one error and one warning.
  23.  
  24. I have to retreat from my earlier position.  The ANSI C standard 
  25. requirement (2.1.2.2.1 and 2.1.2.2.3) is not in a "constraint" section,
  26. so a diagnostic is not strictly required.  The result of defining
  27. main() with a return type of void is therefore undefined -- an
  28. "unconstrained error".
  29.  
  30. Many unconstrained errors are very difficult or even impossible to
  31. detect, which is why the Standard differentiates them from
  32. constraint violations.  The return type of main() is always detected!
  33.  
  34. A compiler may diagnose unconstrained errors, and I would expect a
  35. compiler to diagnose this one, if only in "strict" mode.  (A
  36. "warning" is a diagnostic, for example.)
  37.  
  38. For C++, the ARM does not address required diagnostics.  It does say
  39. that main() returns a value to the environment; this would exclude a
  40. definition with return type void.
  41. -- 
  42.  
  43. Steve Clamage, TauMetric Corp, steve@taumet.com
  44. Vice Chair, ANSI C++ Committee, X3J16
  45.