[Mono-list] [PATCH] Const fold for AddressOf/Indirect
Miguel de Icaza
28 Jul 2002 18:14:50 -0400
> > Here is a trivial patch to fix a crash which I discovered when trying to
> > stress the parser. Unary expressions '& 1' and '* 1' (AddressOf and
> > Indirect) currently crash mcs when it tries to perform constant
> > folding. Shall I apply to CVS?
> This patch is actually incorrect, because it is not valid to take the
> address of a constant, so this code should emit the corresponding error
> instead of silently generating incorrect code.
I have now reworked this piece of code. Now it no longer assumes that
constant reduction will always succeed (as this bug showed). But now,
constant reduction for unary operators will return a flag indicating
whether this reduction is possible or not, instead of the current
This also means that a number of other tests that previously were not
done for constants will be performed.