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] Fix type correctness of fold_indirect_ref


Richard Guenther wrote:

Well, I'm not very familiar with side-effects the following can cause,
but, the following patch moves the optimization to the C++ frontend,
thereby fixing the temp1.C regression.

If this is generally ok I'll throw it at bootstrap & regtesting over night.

I do not believe this is safe.


It might be possible to do that if we kept track of lvalues and rvalues more carefully in the C++ front end, which we would like to do, but that is not done at present. Until it is, the change you're making might result in replacing "*(const int*)&i" (where "i" is an "int") with "i", an expression of type "int", which is wrong. For example, the original expression cannot be trivially bound to an "int &", but "i" can be.

Furthermore, the C++ front end probably shouldn't be doing this kind of optimization anyhow; we really want it to be faithful to the source representation to the extent reasonable. (See extensive previous discussions on this point.) It may be that the C++ gimplifier should be doing this, but not the front end proper.

--
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]