🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2402

Re: const pointer confusion...

#2402
From: Jerry Coffin
Date: Wed, 27 Mar 1996 00:58
32 lines
1838 bytes
In article <4j639l$3ju@solutions.solon.com>, c2a192@ugrad.cs.ubc.ca says...
[ ... ] 

> There
> are some semantic restrictions on this syntactic freedom: a storage class
> specifier may appear only once, for instance, as may a type specifier:
> 
> 	int typedef extern auto foo;
> 
> is syntactically valid, but semantically incorrect, because it has three
> storage specifiers.

To use the wording from the standard, this violates a constraint.
 
> >  Which is a constant pointer to a constant integer; neither *p nor 
> >p can change.
> 
> Wrong. ``const int const'' is just a redundancy. It is the same as ``const
> int'' or ``int const''. A well-written compiler should warn you that you
> have the same type qualifier appearing twice.
> 
> In fact I just tried it with GCC and, indeed!, it warns about ``duplicate
> const'' in the declaration! Hooray!

This is also a constraint violation, so a conforming implementation must 
"issue a diagnostic" which is generally taken to mean an error message rather 
than a warning.  Warnings can (and generally are) given for code that's legal 
but may do unintended things, where errors are given for code that's actually 
illegal.  (If more gets dicussed along this line, it might be best to move it 
to comp.std.c?)
    Later,
    Jerry.
Technical Details
Message-ID: <4ja3rl$pa9@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4j06gm$7oa@solutions.solon.com><4j41hs$nku@solutions.solon.com><4j639l$3ju@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: jcoffin@rmii.com (Jerry Coffin)
Newsgroups: comp.lang.c.moderated
Subject: Re: const pointer confusion...
Date: 26 Mar 1996 18:58:29 -0600
Organization: TAEUS
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4ja3rl$pa9@solutions.solon.com>
References: <4j06gm$7oa@solutions.solon.com><4j41hs$nku@solutions.solon.com><4j639l$3ju@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: MicroPlanet News32 v1.00 Beta Build 302