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

ppci-cc: floating point constants with an exponent but no decimal point are rejected #96

Open
tstreiff opened this issue Jun 23, 2020 · 2 comments
Assignees
Labels
bug C frontend Issues related to the C language compiler

Comments

@tstreiff
Copy link
Contributor

Current version rejects constants such as 12e3.

f = 12e3;
^ Expected ";", got "ID"

but constants like 1.2e4 are accepted.
Since there is no decimal point the lexer takes "12" for an integer constant, and assumes that "e3" is part of an following ID.

The C standard specifies that a decimal floating point constant may be:

[digit-sequence] . digit-sequence [exponent-part]
digit-sequence . [exponent-part]
digit-sequence exponent-part

@windelbouwman windelbouwman added C frontend Issues related to the C language compiler bug labels Jul 5, 2020
@windelbouwman windelbouwman self-assigned this Jul 12, 2020
@windelbouwman
Copy link
Owner

This should be fixed by commit 0e9e024.

@tstreiff could you verify and close if this is working fine now?

@tstreiff
Copy link
Contributor Author

I have tested a few cases.
12e3 is now accepted correctly.

However, the following constants are still rejected by the parser (they are mostly corner cases):
0.7e0
0.
0e1
0e-0
The following constant makes the IR generator crash:
78E-1
The following constant is accepted silently although it should be flagged as too big:
9.0E122334
Last, any floating point constants with a suffix is rejected by the parser (f, F, l, L)
1.2e10f

I attach below a test file (issue96.c) covering most cases, including the failed ones listed above.
issue96.c.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C frontend Issues related to the C language compiler
Projects
None yet
Development

No branches or pull requests

2 participants