🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1497

gcc and g++ warnings

#1497
From: Winfried Koenig
Date: Tue, 29 Dec 1992 22:32
82 lines
2858 bytes
Hello,

when I compile the enclosed program with gcc (2.3.3) I get warning
messages. The essential message parts are enclosed in the comment.
I think, that messages marked with '!!' are ok but I don't understand
the reason for messages marked with '??'. Some messages are marked
with '!?', I think they should better read: '... discards `const' from ...'.

When I compile the same program with g++ I get no '??' message but
there is also no message for the lines marked with '???'.

Any comments?

Winfried

----------------------- cut ----------------
char ar[] = "foobar";
const char *st = "blub";
const char *const cpc = "wau";

int
main ()
{
  char *p;
  const char *pc;

  char **pp;
  const char **ppc;
  const char *const *pcpc;
  const char *const *const cpcpc = &cpc;

  void xpp (char **);
  void xppc (const char **);
  void xpcpc (const char *const *);

  p = ar;
  p = st;	/* !! assignment discards `const' from pointer target type */
  pc = ar;
  pc = st;

  pp = &p;
  pp = &pc;	/* !? assignment from incompatible pointer type */
		/* ??? no error if compiled with g++ !!!! */
  pp = &cpc;	/* !? assignment from incompatible pointer type */

  ppc = &p;	/* ?? assignment from incompatible pointer type */
  ppc = &pc;
  ppc = &cpc;	/* !! assignment discards `const' from pointer target type */

  pcpc = &p;	/* ?? assignment from incompatible pointer type */
  pcpc = &pc;
  pcpc = &cpc;

  cpcpc = &p;	/* !! assignment of read-only variable `cpcpc' */
  		/* !? assignment from incompatible pointer type */
  cpcpc = &pc;	/* !! assignment of read-only variable `cpcpc' */

  xpp (pp);
  xpp (ppc);	/* !? arg of `xpp' from incompatible pointer type */
		/* ??? no error if compiled with g++ !!!! */
  xpp (pcpc);	/* !? arg of `xpp' from incompatible pointer type */
  xpp (cpcpc);	/* !? arg of `xpp' from incompatible pointer type */

  xppc (pp);	/* ?? arg .. from incompatible pointer type */
  xppc (ppc);
  xppc (pcpc);	/* !! arg .. discards `const' from pointer target type */
  xppc (cpcpc);	/* !! arg .. discards `const' from pointer target type */

  xpcpc (pp);	/* ?? arg .. from incompatible pointer type */
  xpcpc (ppc);
  xpcpc (pcpc);
  xpcpc (cpcpc);

  return 0;
}
----------------------- cut ----------------

-- 
Winfried Koenig        win@in.rhein-main.de
Arendsstrasse 12       win@in.sub.org
6050 Offenbach         +49 69 868707
Germany
Technical Details
Message-ID: <m0n6nbo-0001XrC@incom.rhein-main.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!in.rhein-main.DE!win

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!in.rhein-main.DE!win
From: win@in.rhein-main.DE (Winfried Koenig)
Subject: gcc and g++ warnings
Message-ID: <m0n6nbo-0001XrC@incom.rhein-main.de>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 29 Dec 1992 22:32:11 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 83