🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50402

exact meaning of (const char **) ??

#50402
From: Jim Avera
Date: Wed, 06 Oct 1993 23:46
29 lines
1791 bytes
/*
What, exactly, are gcc's rules for assignments between types involving const?

I was under the impression that assignments which strictly reduce write
access (increase "constness") should be accepted without warning, while
assignments which might indirectly grant write access to read-only data
should be flagged.

However, gcc claims that assignment of a (const char **) to a value
of type (char **) is a "pointer mismatch", while the equivalent
code using an explicitly named intermediate pointer compiles without warning.
I don't see how any sneak-path write access is granted, either way.
There must be some other criteria.

Can someone explain this, or state succinctly gcc's algorithm for declaring
pointer mismatches?

-Jim Avera  	jima@netcom.com
*/
int *pi;
int **ppi;
const int *pI;		/*writable ptr to read-only mem*/
const int **ppI;	/*writable ptr to writable ptr to read-only mem*/
void main() {
	pI = pi; ppI = &pI;	/* this is OK */
	         ppI = π	/* but this is "incompatible pointer". (why?) */
	/* the above 2 lines seem completely equivalent */
	         ppI = ppi;	/* and so is thie an "incompatible pointer" */
}
Technical Details
Message-ID: <jimaCEI21G.299@netcom.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!sol.ctr.columbia.edu!news.kei.com!yeshua.marcam.com!charnel!rat!decwrl!amd!amdahl!netcomsv!netcom.com!jima

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,b52f7badb0e36844,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-10-06 20:34:39 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!sol.ctr.columbia.edu!news.kei.com!yeshua.marcam.com!charnel!rat!decwrl!amd!amdahl!netcomsv!netcom.com!jima
From: jima@netcom.com (Jim Avera)
Subject: exact meaning of (const char **) ??
Message-ID: <jimaCEI21G.299@netcom.com>
Keywords: const gcc
Organization: NETCOM On-line Communication Services (408 241-9760 guest)
Date: Wed, 6 Oct 1993 23:46:27 GMT
Lines: 29