On Mon, 1 Jul 2013 12:02:45 +0200, Hans de Goede said: >Unaligned accesses on architectures which don't support it, either get >trapped and emulated (with a fat warnign logged somewhere), or get trapped >and terminate the program. So I don't think this may cause "subtle" bugs. > >I do agree it could happen though. The best way to deal with this is probably >to document the alignment requirements and add casts to silence the warning.
You mean the second best way, no? :) The *best* thing to do would be to actually fix the code. I've brought up this Wcast-align warning months ago: <http://www.mail-archive.com/libusbx-devel@lists.sourceforge.net/msg01599.html> IIRC, a proper fix would require an API change. I don't think Paul's patch should be committed, at least not as-is. It adds strange double casts (with no comment) that future readers of the code will wonder about, and it's just a hack that leaves the false impression of something being fixed. Why is it so important that libusb.h work with -Werror=cast-align anyway? I think it would be better to add to the top of libusb.h the following: #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-align" #endif then this at the bottom: /* On gcc 4 and later, restore disabled warning */ #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))) #pragma GCC diagnostic pop #endif This makes it clear a temporary hack is in place until the API can be fixed. Cheers, -- ____________________________________________________________ Sean McBride, B. Eng s...@rogue-research.com Rogue Research www.rogue-research.com Mac Software Developer Montréal, Québec, Canada ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel