This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Set TREE_READONLY const POD arrays with size determined from initialize (PR c++/21454)

On Wed, May 11, 2005 at 06:37:53PM -0400, Paul Schlie wrote:
> > Jakub Jelinek <> writes:
> >
> > This is a fallout of the PR c++/20073 fix.
> > For arrays like:
> > const int a[] = { 0, 1, 2, 3 };
> > when cp_apply_type_quals_to_decl is called, its type is not complete yet,
> > so C++ frontend does not set TREE_READONLY flag.  But such variables
> > aren't put into incomplete_vars chain either, so nothing sets the flag
> > afterwards.
> > Ok for 4.0/HEAD if it passes regtesting?
> What's the difference between TREE_READONLY and MEM_READONLY_P ?

TREE_READONLY is a tree flag, MEM_READONLY_P is a rtl flag.
They both mean basically the same thing, that the object is not modified
once the program gets control (i.e. e.g. variables in read-only sections are
ok, variables in writable sections that are there just because they need to
be relocated by the dynamic linker (which is even before constructors are
run) and are never modified afterwards are ok too).

> (To the best of my knowledge "const int a[]" is allocated and initialized
>  at run-time in RAM with the READONLY ROM literal value "{1,2,3,4}"; so a[]
>  is not READONLY, although it's literal initializer is; as opposed to
>  "static const a[] = {0,1,2,3}" where they are considered equivalent.)

No, there is no difference outside of function body whether there is
static keyword or not.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]