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

1.0/0 and 0.0/0 are both defined, but are reported as an error by rcc #442

Closed
jyn514 opened this issue May 20, 2020 · 2 comments · Fixed by #444
Closed

1.0/0 and 0.0/0 are both defined, but are reported as an error by rcc #442

jyn514 opened this issue May 20, 2020 · 2 comments · Fixed by #444
Labels
bug Something isn't working const_fold Constant propogation at compile time error-checking good first issue Good for newcomers

Comments

@jyn514
Copy link
Owner

jyn514 commented May 20, 2020

Expected behavior

1.0 / 0 should be +INF, 0.0 / 0 should be NaN.

Code

<stdin>:1:11 error: invalid program: cannot divide by zero
float f = 1.0 / 0;
          ^^^^^^^
<stdin>:1:11 error: invalid program: cannot divide by zero
float f = 0.0 / 0;
          ^^^^^^^

Annex F: floating point arithmetic (http://port70.net/~nsz/c/c11/n1570.html#F)

1 The C floating types match the IEC 60559 formats as follows:
- The float type matches the IEC 60559 single format.
- The double type matches the IEC 60559 double format.
- The long double type matches an IEC 60559 extended format,357) else a non-IEC 60559 extended format, else the IEC 60559 double format.

We should also define __STDC_IEC_559__, as per 6.10.8.3.

@jyn514 jyn514 added bug Something isn't working error-checking const_fold Constant propogation at compile time labels May 20, 2020
@jyn514 jyn514 added this to the Preprocessor for bindgen milestone May 20, 2020
@jyn514
Copy link
Owner Author

jyn514 commented May 20, 2020

Found in rust-lang/rust-bindgen#1782

@jyn514 jyn514 added the good first issue Good for newcomers label May 20, 2020
@jyn514
Copy link
Owner Author

jyn514 commented May 20, 2020

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working const_fold Constant propogation at compile time error-checking good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant