Skip to content

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

@phlummox

Description

@phlummox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions