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: -funswitch-loops not effective?

On Tue, 18 Jan 2005 20:51:37 +0100, Giovanni Bajo <> wrote:
> Mark Mitchell <> wrote:
> >>> Of course, this doesn't say where there is the well-formed
> >>> leak of a pointer to the const member in the class in the first
> >>> place:
> >>>
> >>> class Foo {
> >>> public:
> >>>   Foo(bool b) : flag(b) {}
> >>>   bool get() const { return flag; }
> >>> private:
> >>>   const bool flag;
> >>> };
> >>>
> >>> Is there a well-formed way to write to Foo::flag?
> >
> > Yes -- but only during the constructor for Foo.  After that point, it
> > cannot change.
> Actually, to clarify, only within the member initialization list of Foo's
> constructor, where you can explicitally call the const member's constructor.
> After that, the body of the construct of Foo is no different from other
> member functions, in that it cannot modify the const member's contents.

So to take this one step further - a Flag object passed as const Flag&
cannot have its flag member changed in any way, and as such not by
side-effects of a called function?  If so, why don't we model this
invariant and exploit it in the optimizers?


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