🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1068

Re: Re: Is `char const *foo;' legal?

#1068
From: Walter Murray
Date: Fri, 12 Jan 1990 19:37
28 lines
1476 bytes
[Regarding a declaration like "const char bar[]"]
 
[Description of how GCC interprets this]

>| I have found no basis in the standard for either this binding *or* for the
>| other alternative (i.e. binding the `const' more tightly than the `[]').
>| Did I miss something?  Which binding is "correct"?  Why?

In this example, "bar" has type "array of const char".  The const qualifier
applies to the element type, not the array type.

Here are relevant sections from the Standard (quoting from the 12/7/88
draft):

The type of an array is defined by 3.5.4.2, page 68, lines 6-10.
The inductive method used to define the type of a derived declarator
can be a little confusing.  See the paragraph in 3.5.4 beginning on 
page 66, line 45, for an explanation.

Section 3.1.2.5, page 25, lines 22-23:  "A derived type is not
qualified by the qualifiers (if any) of the type from which it
is derived."

If you try to use a typedef to force the array type itself to be
qualified, it won't work.  Section 3.5.3, page 65, lines 23-25.

Walter Murray
----------
Technical Details
Message-ID: <12570037@hpclwjm.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!usc!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclwjm!walter
References: <MEISSNER.90Jan11104148@pmax27.osf.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!usc!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclwjm!walter
From: walter@hpclwjm.HP.COM (Walter Murray)
Newsgroups: comp.std.c
Subject: Re: Re: Is `char const *foo;' legal?
Message-ID: <12570037@hpclwjm.HP.COM>
Date: 12 Jan 90 19:37:47 GMT
References: <MEISSNER.90Jan11104148@pmax27.osf.org>
Organization: Hewlett-Packard Calif. Language Lab
Lines: 28