This is the mail archive of the gcc-patches@gcc.gnu.org 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) €


Paul Schlie wrote:
Jakub Jelinek <jakub@redhat.com> 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 ?

(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.)

I'm not sure exactly what you're asking. But, "a" should be TREE_READONLY in that case, as there should be no dynamic initialization, and nothing may ever change the value.


It's associated MEM should also be MEM_READONLY_P.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


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