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

UB due to union based type punning #46

Closed
Flamefire opened this issue Aug 23, 2019 · 1 comment
Closed

UB due to union based type punning #46

Flamefire opened this issue Aug 23, 2019 · 1 comment

Comments

@Flamefire
Copy link

uses an union to convert a float to an int. This has 2 problems each causing UB:

  1. a float may not be a IEEE754 float (I think this can be checked via defines)
  2. Accessing an inactive union member is UB (this can be fixed by a memcpy which is optimized away by the compiler)
@igaztanaga
Copy link
Member

  1. The implementation does not support anything that is not IEEE754, which is extremly rare there days, so this won't be fixed.

  2. As you suggest, a memcpy is the correct fix.

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

No branches or pull requests

2 participants