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

Produces non-portable C code (over-length string literals) #43

Open
phlummox opened this issue Feb 24, 2020 · 0 comments
Open

Produces non-portable C code (over-length string literals) #43

phlummox opened this issue Feb 24, 2020 · 0 comments

Comments

@phlummox
Copy link

hsc2hs does not seem to place a limit on how long the "tokens" it produces while parsing can be. Consequently, they can easily result in the generated C code containing string literals which exceed the 4095 character limit which ISO C99 compilers are required to support.

This is the case when running hsc2hs on the attached Test.hsc file. Running hsc2hs Test.hsc does indeed produce a Test_hsc_make.c file with over-long literals. (Adding --cflag=-pedantic to the invocation makes this more obvious.)

I tried the same thing on the "Lens.Micro" source file from the microlens package (first renaming it from Micro.hs to Micro.hsc), and confirmed this occurs with that file, too - so literals of that length certainly occur in existing packages.

The cause seems to be that the length of tokens produced by the text Parser in HSCParser.hs is never checked.

Even if this isn't regarded as a bug, it might be helpful to note in the documentation that the output of hsc2hs may be non-portable C.

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

1 participant