Questions about a constant array reference in the C++ front end
Paul Schlie
schlie@comcast.net
Tue May 10 05:20:00 GMT 2005
> From: Paul Schlie <schlie@comcast.net>
>> From: Mark Mitchell <mark@codesourcery.com>
>>> Paul Schlie wrote:
>>> - ??? no such thing, you can't "dynamically" initialize a "static const",
>>> as then it's not a "static const", but rather simply a global "const"
>>>
>>> (as a "static const" object is logically equivalent to a named/addressable
>>> literal, yes?)
>>
>> No, it's not.
>>
>> static const int i = f();
>
> Admittedly didn't think that was legal, as I though all "static const"
> initializer values needed to be resolvable at compile time, directly or
> indirectly from literal values by the front-end, or otherwise invalid.
So then more accurately, MEM_READONLY_P is only "true" for references to:
- "static const" objects which are equated to a literal initializer.
- or an arbitrary literal value which has not been in-lined into the code,
as it's either too large to be done efficiently, or may be referenced
indirectly via a pointer.
(is this essentially correct?)
More information about the Gcc
mailing list