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

Use unsigned integers #78

Merged
merged 19 commits into from
Aug 27, 2021
Merged

Use unsigned integers #78

merged 19 commits into from
Aug 27, 2021

Conversation

j-hui
Copy link
Collaborator

@j-hui j-hui commented Aug 12, 2021

Fix for #32 by using C's unsigned integers to represent SSM signed types.

Also includes some reorganization of SSM.Backend.C to isolate more of the type-related eccentricities within SSM.Backend.C.Types.

@j-hui j-hui requested a review from Rewbert August 12, 2021 21:09
@j-hui j-hui changed the title Use unsigned integers [do not merge] Use unsigned integers Aug 12, 2021
ssm/SSM/Backend/C/Types.hs Outdated Show resolved Hide resolved
ssm/SSM/Backend/C/Types.hs Outdated Show resolved Hide resolved
@j-hui
Copy link
Collaborator Author

j-hui commented Aug 26, 2021

@Rewbert fixed according to your suggestions, and ready for review!

Now, there is one issue in #32 that remains to be addressed. This patch fixes the undefined behavior of signed integer over/underflow in C, but does not do anything to address the undefined behavior in Haskell. It so happens that on our current dev environment, Haskell's Int type does more or less what we expect it to, but there's not much of a guarantee that will continue to be the case.

To fix that, should I fix the interpreter to perform arithmetic using Integer and manually perform over/underflow checks + wrapraound? That may incur a noticeable penalty for testing, so I can understand the argument for punting on this and fixing it when it only once we find issues in tests (since this doesn't technically affect the correctness of our generated code).

@Rewbert
Copy link
Collaborator

Rewbert commented Aug 26, 2021

I'd say skip for now, but leave the issue open :)

@Rewbert Rewbert merged commit 6a30f83 into master Aug 27, 2021
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

Successfully merging this pull request may close these issues.

2 participants