-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Packed etl::unaligned_type #988
Comments
The 'packed' attribute would have to be defined in something like |
I.e. like this: #989 ? |
Adding packed keyword doesn't give you any benefit, the point of these unaligned types that they are already packed |
Consider this code with a simplified etl::unaligned_type:
With GCC, it correctly prints:
However, it gives this warning:
Turns out to be a known GCC issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83732 (Clang doesn't have this issue.) The change in #989 fixes the issue, although it can rather be considered a GCC workaround and not an actual packing issue. We can document this fact where ETL_PACKED is applied to unaligned_type. |
Yes, this is more of a GCC specific fix, but Eg.
|
I have no problem compiling this: #include "etl/unaligned_type.h"
struct slim
{
etl::le_uint8_t a;
etl::le_uint32_t b;
};
static_assert(sizeof(slim) == 5); so I still don't see what is the benefit of bringing in the mess with the packed attribute. |
You are not using the packed attribute in your application code (using ETL). Imagine a codebase that uses the packed attribute (as I regularly experienced). Then, with GCC, the warning is generated, as noted above. |
Hi!
I'm using etl::unaligned_type in a packed struct like this:
Unfortunately, with gcc, this results in:
Example.cpp:23:24: error: ignoring packed attribute because of unpacked non-POD field ‘etl::be_uint16_t {anonymous}::B::x’ [-Werror]
I traced this to the fact that etl::unaligned_type is a nested struct/class, including etl::private_unaligned_type::unaligned_type_common within etl::unaligned_type.
Now, when I add the packed attribute just to the outer class etl::unaligned_type, the problem goes away:
What do you think? Would it be reasonable to add this to unaligned_type? Or would you suggest sth. different?
Using the ARM GCC Toolchain:
The text was updated successfully, but these errors were encountered: