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

Bug: unaligned_type doesn't compile with floating point types #917

Closed
enbyted opened this issue Jul 10, 2024 · 2 comments
Closed

Bug: unaligned_type doesn't compile with floating point types #917

enbyted opened this issue Jul 10, 2024 · 2 comments
Assignees
Labels

Comments

@enbyted
Copy link

enbyted commented Jul 10, 2024

unaligned_type<T, Entian> claims to support any T that is either integral or floating point. There are also type aliasses for float, double and long double.

Unfortunately, the unaligned_copy algorithm does not support those correctly, fails with the following error:

etl/include/etl/unaligned_type.h:464:54: error: invalid operands of types ‘float’ and ‘unsigned int’ to binary ‘operator>>’
   464 |           store[1] = static_cast<storage_type>(value >> (1U * CHAR_BIT));
       |                                                ~~~~~~^~~~~~~~~~~~~~~~~~
@jwellbelove
Copy link
Contributor

I'm looking at removing the equality and inequality operators as

  1. They do not add any real functionality to etl::unaligned_type.
  2. If they are included then the other numerical operators should logically be included.
  3. They hide the conversion to and from the underlying type that is going on to enable the comparison. This is especially true of the floating point types as the they can have an implementation defined amount of padding.

@jwellbelove
Copy link
Contributor

Fixed 20.39.3

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

No branches or pull requests

2 participants