This is the mail archive of the gcc@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: Q: C++ FE emitting assignments to global read-only symbols?


Dale Johannesen <dalej@apple.com> wrote:

>> I do think the C++ FE needs fixing before Diego's change gets merged,
>> though.  I can make the change, but not instantly.  If someone files
>> a PR, and assigns to me, I'll get to it at some not-too-distant
>> point.
>
> It would be good to have a way to mark things as "write once, then
> readonly" IMO.
> It's very common, and you can do some of the same optimizations on
> such things
> that you can do on true Readonly objects.


We had this once, it was called RTX_UNCHANGING_P, and it was a big mess.
Progressively, we have been removing TREE_READONLY from C++ const variables
(which are "write once" from the GCC IL point of view), and this is another
instance of the same problem.

We probably need a better way to describe C++ constructors, maybe something
like WRITEONCE_EXPR which is a MODIFY_EXPR with a READONLY on its lhs, and
which is supposed by the frontends when initialing such variables.

Giovanni Bajo


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