This is the mail archive of the
mailing list for the GCC project.
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.