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

Integer overflow w/ generated lexer #47

Closed
netshade opened this issue Jun 13, 2022 · 2 comments · Fixed by #29
Closed

Integer overflow w/ generated lexer #47

netshade opened this issue Jun 13, 2022 · 2 comments · Fixed by #29

Comments

@netshade
Copy link

I was attempting to compile a lexer generated w/ the Rust backend, and I got the following errors on my tokens:

error: this arithmetic operation will overflow
     |
8379 | ...ze << (FLOAT - 1)) | (1usize << (VALID_IDENTIFIER - 1)) | (1usize << (FIELD - 1)) | (1usize << (INDEXED_FIELD - 1)))) != 0) {
     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left by `61_isize`, which would overflow

I think this is because the template portion that is doing a bitset emulation of the Antlr code is presuming that 1usize is 64-bit width trying to match the original implementation?.

If my understanding here is correct, should it be that the template is instead masking with 1u64 instead ? Happy to provide a PR if this is right.

@netshade netshade changed the title wasm32 compatibility Integer overflow w/ generated lexer Jun 13, 2022
@netshade
Copy link
Author

( This came about because I was compiling for wasm32-unknown-unknown - on other architectures it worked as expected )

@netshade
Copy link
Author

( After looking at the template some more I see that this definitely is not quite so simple as that. Are the semantics of the parser more or less locked in at "everything must be word sized which is also 64 bits", or is it possible to be explicit that everything is 64 bits here? )

@rrevenantt rrevenantt mentioned this issue Jul 5, 2022
36 tasks
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 a pull request may close this issue.

1 participant