Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Hexadecimal floating constant requires an exponent #483

Closed
hdamron17 opened this issue Jul 6, 2020 · 3 comments · Fixed by #484
Closed

Hexadecimal floating constant requires an exponent #483

hdamron17 opened this issue Jul 6, 2020 · 3 comments · Fixed by #484

Comments

@hdamron17
Copy link
Collaborator

According to the grammar in 6.4.4.2, hexadecimal floating constants require a binary exponent (p). A binary exponent of 0 is used to bypass this restriction. Not sure if it's anything we should worry about because we are less restrictive than the C standard.

Code Example

int printf(const char *format, ...);
int main() {
  printf("%f\n", (0x1.5));
}

Expected Compilation Error (clang)

test.c:3:24: error: hexadecimal floating constant requires an exponent
  printf("%f\n", (0x1.5));
                       ^
1 error generated.

Actual Behavior: no error with output

1.312500
@jyn514
Copy link
Owner

jyn514 commented Jul 6, 2020

This is known and expected behavior, see
https://docs.rs/hexponent/0.3.1/hexponent/#differences-from-the-specification. Where do you think would be a good place to document this?

@hdamron17
Copy link
Collaborator Author

Ah, you could mention it in you IMPLEMENTATION_DEFINED.md section. Or it's probably fine to just leave it off- I just noticed this as I was exploring parse_num for the big migration (and I doubt most users will be digging that deep).

@jyn514
Copy link
Owner

jyn514 commented Jul 6, 2020

I don't expect most people to read through IMPLEMENTATION_DEFINED.md anyway so I can put it in there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants