Open GoogleCodeExporter opened 8 years ago
I have got more or less the same problem:
This is c source code:
...
char status[3];
...
if (status[0] != 0 && status[0] != 3 && status[0] != 4)
{
...
}
...
output is: "this is not an array", generated in funtion:
ExpressionInfixOperator ln 618 of PicoC Expression.c
If i change source in this form it seems to work correctly:
if ( (status[0] != 0) && (status[0] != 3) && (status[0] != 4) )
{
}
has anyone tried?
Original comment by daniele....@gmail.com
on 16 Dec 2011 at 9:52
Brackets ... if not sure always use them :)
Original comment by zahari.z...@gmail.com
on 16 Dec 2011 at 2:32
Sorry, have you tried using brackets in test.c file? For me it works...
Original comment by daniele....@gmail.com
on 19 Dec 2011 at 10:01
It's related to this optimization:
expression.c:1129:
/* if it's a && or || operator we may not need to evaluate the right hand side
of the expression */
Original comment by broscuta...@gmail.com
on 5 Mar 2013 at 8:34
If you comment out this, it seems to work:
/* if we've successfully ignored the RHS turn ignoring off */
if (Precedence <= IgnorePrecedence)
IgnorePrecedence = DEEP_PRECEDENCE;
I'm not sure what this does, and what side effects this change might have. The
built-in tests run fine regardless of those two lines.
Original comment by broscuta...@gmail.com
on 5 Mar 2013 at 9:50
Nope, this fix is not good. Disabling the boolean optimization seems better.
Another test case:
struct point {
double x;
double y;
};
int isInBetween (struct point p1, struct point p2, struct point t) {
int valid = FALSE;
if ((t.x >= p1.x && t.x <= p2.x) || (t.x >= p2.x && t.x <= p1.x)) {
if ((t.y >= p1.y && t.y <= p2.y) || (t.y >= p2.y && t.y <= p1.y)) {
valid = TRUE;
}
}
return valid;
}
from http://www.go-hero.net/jam/12/name/dahlukeh , Hall of Mirrors
Original comment by broscuta...@gmail.com
on 6 Mar 2013 at 8:17
There is some truth in the "fix" from #5. Here's a better version, that passed
everything I've thrown at it so far.
https://bitbucket.org/a1ex/picoc-fork/commits/f4b78691c054b7b7b8d63e41dbbe6646d0
37fb77
I'd like you to review this one, because I still don't fully understand how
IgnorePrecedence works.
Original comment by broscuta...@gmail.com
on 16 Mar 2013 at 3:03
Original issue reported on code.google.com by
zahari.z...@gmail.com
on 5 Mar 2011 at 1:06Attachments: