home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13379 < prev    next >
Encoding:
Text File  |  1992-09-08  |  791 b   |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mcsun!sun4nl!wn1.sci.kun.nl!sci.kun.nl!leo
  3. From: leo@sci.kun.nl (Leo Willems)
  4. Subject: const * const return value
  5. Message-ID: <1992Sep7.210827.10793@sci.kun.nl>
  6. Summary: bad return value for const * const
  7. Keywords: const pointer
  8. Sender: news@sci.kun.nl (NUnet News Owner)
  9. Organization: University of Nijmegen, The Netherlands
  10. Date: Mon, 7 Sep 1992 21:08:27 GMT
  11. Lines: 27
  12.  
  13.  
  14. Is the returntype const char * const legal when it is assigned to a const char*:
  15.  
  16. const char * const
  17. f()
  18. {
  19.     return "aa";
  20. }
  21.  
  22. void
  23. x()
  24. {
  25.     const char * p = f();   // legal assignment??
  26.  
  27.     ++p;            // sigh
  28. }
  29.  
  30. cfront 3.0.1 is accepting this, according to me it breaks the meaning
  31. of a const pointer to const. Is there an explanation?
  32.  
  33. Please E-mail to leo@atcmp.nl
  34.  
  35. Thanks.
  36.  
  37.  
  38. Leo
  39.  
  40.