Produces non-portable C code (over-length string literals)
- Dominant language
- Haskell
- Stars
- 46
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
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](https://github.com/haskell/hsc2hs/files/4243103/Test.hsc.txt) 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"](https://hackage.haskell.org/package/microlens-0.4.11.2/docs/Lens-Micro.html) 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.