home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / g / bug / 2079 < prev    next >
Encoding:
Text File  |  1992-12-27  |  1.4 KB  |  62 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!csc000.CSc.ti.COM!picone
  3. From: picone@csc000.CSc.ti.COM (Joe Picone)
  4. Subject: Warning message: control reaches end of non-void function
  5. Message-ID: <PICONE.92Dec26044229@csc000.csc.ti.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Tsukuba Research and Development Center
  8. Distribution: gnu
  9. Date: Sat, 26 Dec 1992 10:42:35 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 49
  12.  
  13. This code:
  14.  
  15. #include <stdlib.h>
  16.  
  17. class foo {
  18. private:
  19.   int x;
  20. public:
  21.   foo() {};
  22.   int check(int i);
  23.   volatile void exit_handler() {exit(-1);}
  24. };
  25.  
  26. int foo::check(int i) {
  27.   if (i > 0)
  28.     {exit_handler();}
  29.   else
  30.     {return 0;}
  31. }
  32.  
  33. volatile void foo1() {exit(1);}
  34.  
  35. int foo2 (int argc) {
  36.   if (argc > 2)
  37.     {foo1();}
  38.   else
  39.     {return 0;}
  40. }
  41.  
  42.  
  43. produces the following warning message when compiled with 
  44. "gcc -c -Wall foo.C":
  45.  
  46.     warning: control reaches end of non-void function
  47.  
  48. Note that this only occurs with the member function version of this
  49. example. The function version, included above, doesn't produce a
  50. warning message.
  51.  
  52. This is no doubt the result of some compiler magic going on behind the
  53. scenes, but here is my question:
  54.  
  55. Shouldn't the declaration of the member function as volatile void
  56. prevent such a warning message from occurring?
  57.  
  58. Volatile is supposed to be used when the function might never return,
  59. so why doesn't the compiler turn off the warning message in this case?
  60.  
  61.  
  62.