On Tue, May 5, 2020 at 6:57 PM Pavel Machek <pavel@xxxxxxx> wrote: > On Tue 2020-05-05 11:32:27, Sasha Levin wrote: > > On Tue, May 05, 2020 at 05:05:37PM +0300, Andy Shevchenko wrote: ... > > I'm a bit confused about this too. Maybe it's too early in the morning, > > so I wrote this little test program: > > > > #include <stdio.h> > > #include <stdlib.h> > > > > int main(int argc, char *argv[]) > > { > > int a = atoi(argv[1]); > > int b = atoi(argv[2]); > > > > if (!a && !b) > > printf("A"); > > else > > printf("B"); > > > > if (!(a || b)) > > printf("A"); > > else > > printf("B"); > > > > printf("\n"); > > > > return 0; > > } > > > > Andy, could you give an example of two values which will print something > > other than "AA" or "BB"? > > The issue here is "sideffects". Does b have to be evaluated at all? > There is no difference between > > int a, b; > if (a && b) > > and > > if ((!!a) & (!!b)) > . > > But there would be difference between > > int a, b; > if (a && b++) > > and > if ((!!a) & (!!(b++))) > > But: > > 1) && and || behave same way w.r.t. side effects > > 2) in the patch we are talking about b has no important side effects I have to admit that this seems like a luck and the real issue somewhere else. Definitely another test should be performed. Thank you, Pavel, for pointing this out. -- With Best Regards, Andy Shevchenko