home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / gcc / bug / 3078 < prev    next >
Encoding:
Text File  |  1992-12-30  |  2.7 KB  |  96 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!in.rhein-main.DE!win
  3. From: win@in.rhein-main.DE (Winfried Koenig)
  4. Subject: gcc and g++ warnings
  5. Message-ID: <m0n6nbo-0001XrC@incom.rhein-main.de>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 29 Dec 1992 22:32:11 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 83
  12.  
  13. Hello,
  14.  
  15. when I compile the enclosed program with gcc (2.3.3) I get warning
  16. messages. The essential message parts are enclosed in the comment.
  17. I think, that messages marked with '!!' are ok but I don't understand
  18. the reason for messages marked with '??'. Some messages are marked
  19. with '!?', I think they should better read: '... discards `const' from ...'.
  20.  
  21. When I compile the same program with g++ I get no '??' message but
  22. there is also no message for the lines marked with '???'.
  23.  
  24. Any comments?
  25.  
  26. Winfried
  27.  
  28. ----------------------- cut ----------------
  29. char ar[] = "foobar";
  30. const char *st = "blub";
  31. const char *const cpc = "wau";
  32.  
  33. int
  34. main ()
  35. {
  36.   char *p;
  37.   const char *pc;
  38.  
  39.   char **pp;
  40.   const char **ppc;
  41.   const char *const *pcpc;
  42.   const char *const *const cpcpc = &cpc;
  43.  
  44.   void xpp (char **);
  45.   void xppc (const char **);
  46.   void xpcpc (const char *const *);
  47.  
  48.   p = ar;
  49.   p = st;    /* !! assignment discards `const' from pointer target type */
  50.   pc = ar;
  51.   pc = st;
  52.  
  53.   pp = &p;
  54.   pp = &pc;    /* !? assignment from incompatible pointer type */
  55.         /* ??? no error if compiled with g++ !!!! */
  56.   pp = &cpc;    /* !? assignment from incompatible pointer type */
  57.  
  58.   ppc = &p;    /* ?? assignment from incompatible pointer type */
  59.   ppc = &pc;
  60.   ppc = &cpc;    /* !! assignment discards `const' from pointer target type */
  61.  
  62.   pcpc = &p;    /* ?? assignment from incompatible pointer type */
  63.   pcpc = &pc;
  64.   pcpc = &cpc;
  65.  
  66.   cpcpc = &p;    /* !! assignment of read-only variable `cpcpc' */
  67.           /* !? assignment from incompatible pointer type */
  68.   cpcpc = &pc;    /* !! assignment of read-only variable `cpcpc' */
  69.  
  70.   xpp (pp);
  71.   xpp (ppc);    /* !? arg of `xpp' from incompatible pointer type */
  72.         /* ??? no error if compiled with g++ !!!! */
  73.   xpp (pcpc);    /* !? arg of `xpp' from incompatible pointer type */
  74.   xpp (cpcpc);    /* !? arg of `xpp' from incompatible pointer type */
  75.  
  76.   xppc (pp);    /* ?? arg .. from incompatible pointer type */
  77.   xppc (ppc);
  78.   xppc (pcpc);    /* !! arg .. discards `const' from pointer target type */
  79.   xppc (cpcpc);    /* !! arg .. discards `const' from pointer target type */
  80.  
  81.   xpcpc (pp);    /* ?? arg .. from incompatible pointer type */
  82.   xpcpc (ppc);
  83.   xpcpc (pcpc);
  84.   xpcpc (cpcpc);
  85.  
  86.   return 0;
  87. }
  88. ----------------------- cut ----------------
  89.  
  90. -- 
  91. Winfried Koenig        win@in.rhein-main.de
  92. Arendsstrasse 12       win@in.sub.org
  93. 6050 Offenbach         +49 69 868707
  94. Germany
  95.  
  96.