Operator precedence problem

Posted By: Talemon

Operator precedence problem - 04/28/14 11:49

Hello, I think lite-c operator ordering has a problem. When a statement has both a "member of" operator(i.e. "." and "->") and a subscription operator("[]") it handles the subscription first instead of handling them left-to-right. This causes unnecessary parentheses.

For example:

Quote:
struct ABC
{
int arr[10];
}

ABC ex;
ex.arr[0] = 5;


This causes a "subscript requires array or pointer type" error.
So what I do is:

Quote:
(ex.arr)[0] = 5;


The parentheses can get out of hand quickly and the readability of our code would improve substantially if this was fixed.
Posted By: jcl

Re: Operator precedence problem - 04/28/14 12:20

I confirm the problem. This will be fixed in an update - I think the fix is safe as it most likely won't break existing code.
Posted By: Superku

Re: Operator precedence problem - 04/28/14 12:28

Neat!
Posted By: Talemon

Re: Operator precedence problem - 04/28/14 15:09

Originally Posted By: jcl
I confirm the problem. This will be fixed in an update - I think the fix is safe as it most likely won't break existing code.


Thanks for such a quick response!
Posted By: sivan

Re: Operator precedence problem - 04/28/14 17:53

ohh it would be so great!
Posted By: Uhrwerk

Re: Operator precedence problem - 04/28/14 18:06

Finally...
Posted By: Rackscha

Re: Operator precedence problem - 04/29/14 13:42

Originally Posted By: Uhrwerk
Finally...
© 2024 lite-C Forums