home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / gcc / help / 2846 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.2 KB  |  36 lines

  1. Newsgroups: gnu.gcc.help
  2. Path: sparky!uunet!wupost!howland.reston.ans.net!paladin.american.edu!gatech!swrinde!elroy.jpl.nasa.gov!decwrl!csus.edu!netcom.com!jimlynch
  3. From: jimlynch@netcom.com (Jim Lynch)
  4. Subject: I think I found a bug (or at least an annoyance)
  5. Message-ID: <1993Jan2.143131.6791@netcom.com>
  6. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  7. Date: Sat, 2 Jan 1993 14:31:31 GMT
  8. Lines: 26
  9.  
  10. OK, my example of before, I found out why it was dumping core.
  11.  
  12. When you define:
  13.  
  14. char *x = "abcde" ;
  15.  
  16. is x an implied const? If it is, gcc is not reporting an error it should
  17. be (I think).
  18.  
  19. If I declare a function like this,
  20.  
  21. void y(char &x) ;
  22.  
  23. it's saying I want to modify the value of x within the function. I quote from
  24. Stroustrup, section 4.6.3, "Argument Passing", page 125:
  25.  
  26.   The absence of 'const' in the declaration of a reference argument is taken
  27.   as a statement of intent to modify the variable:
  28.  
  29.       void g(large& arg);  // assumes that g() modifies arg
  30.  
  31. Given this, any const object passed to such a formal parameter should be
  32. flagged as a compiler error.
  33.  
  34. I would personally have appreciated gcc 2.3.2 (sparc.sun.sunos4.1.3) if it
  35. would have done so.
  36.