Hi,
On Wed, 26 Oct 2011, Kai Tietz wrote:
> >> > int f(char *i, int j)
> >> > {
> >> > if (*i && j!=2)
> >> > return *i;
> >> > else
> >> > return j;
> >> > }
> >>
>
> the case can be produced quite easily.
>
> extern int global = 0;
>
> ....
> if (*a && global) ...
See? You had to change the program to prove the transformation to be
invalid. But my point was that the function we discuss about was exactly
as above. It didn't have globals, or two loads, or a volatile, or
anything else you can come up with where the transformation would be
detectable (and hence invalid). I claim that you can't construct a
program that can distinguish between this function:
int f(char *i, int j)
{
if (*i && j!=2)
return *i;
else
return j;
}
and this one:
int f(char *i, int j)
{
if (*i & j!=2)
return *i;
else
return j;
}
And if you can't construct such a program, then the initial transformation
before the fold-const.c change _for this specific situation_ was correct.
Ciao,
Michael.