Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expr.c line 485 is assigning not testing. #8

Open
poetnerd opened this issue Dec 30, 2018 · 4 comments
Open

expr.c line 485 is assigning not testing. #8

poetnerd opened this issue Dec 30, 2018 · 4 comments

Comments

@poetnerd
Copy link
Contributor

Sorry to be raising this in an issue. With all the changes I was working through in my silence-warnings branch, it was only after I did my massive merge that I remembered a single line bug I wanted to report and fix.

Line 485 of expr.c reads:

if ((ch () != '+') & (ch () != '-') | nch() == '=')

I'm pretty sure the intent is not to perform bit masking, but to perform comparison. So the line should read:

if ((ch () != '+') && (ch () != '-') || nch() == '=')

@ncb85
Copy link
Owner

ncb85 commented Dec 30, 2018

I can see & operation also in other hier methods. If I remember correctly it is used instead of logical AND for reasons, SmallC was to be self compiling, but SmallC did not support logical AND itself. The values of operands should ensure, that it actually behaves like logical AND.
Therefore change to logical operation && in single place might not be enough, more corrections and tests would be needed.

@poetnerd
Copy link
Contributor Author

poetnerd commented Dec 30, 2018 via email

@ncb85
Copy link
Owner

ncb85 commented Dec 31, 2018

About line 634. It has been long time since I was focused on SmallC. It really looks like I changed some test to logical while working on struct feature and similar. So someone should finish it properly.

I am using NCB85 SBC with 8085 CPU as test platform. Unfortunately I am rather busy with other projects, and use SmallC only few hours a year.

I would gladly accept patch unifying tests in expr.c and primary.c to use logical operations. I can't promise doing it myself any time soon.
I am using this test suite to test changes to compiler:
https://github.com/ncb85/utilis-and-examples/tree/master/cpm_utest_unit

As I could not test other targets I dropped them, but would also welcome joining them back. So PDP is very welcome.

@poetnerd
Copy link
Contributor Author

poetnerd commented Jan 9, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants