Compiling generates these warnings: sanei_net.c: In function 'sanei_w_option_descriptor_array': sanei_net.c:131: warning: dereferencing type-punned pointer will break strict-aliasing rules sanei_wire.c: In function 'sanei_w_option_descriptor': sanei_wire.c:518: warning: dereferencing type-punned pointer will break strict-aliasing rules sanei_wire.c:525: warning: dereferencing type-punned pointer will break strict-aliasing rules sanei_wire.c:535: warning: dereferencing type-punned pointer will break strict-aliasing rules The solution is to cast to (void *) before casting to (void **). Reproducible: Always Steps to Reproduce: 1. FEATURES="stricter" emerge media-gfx/sane-backends-1.0.19-r2 Actual Results: die "poor code kills airplanes" Expected Results: compiles, installs Bug is filed upstream at https://alioth.debian.org/tracker/index.php?func=detail&aid=311334&group_id=30186&atid=410366
Created attachment 177169 [details] New ebuild that applies patch
Created attachment 177170 [details, diff] Patch to cast to (void *) and eliminate warning
> The solution is to cast to (void *) before casting to (void **). No, absolutely not. That extra cast does nothing whatsoever to fix the problem. It merely tells gcc "shut up, I know what I'm doing", and should be used only when you really do.
Created attachment 177177 [details] adds -fno-strict-aliasing cflag to build Reading the gcc manual and the code, I think this is a case where masking the warning is the right thing. They are using a union to save memory, setting an enumeration to set which union member was written to, etc. In other words, all the things you do to try to simulate C++ polymorphism in C. However, it is upstream's job to decide if they want to mask the warning or write code that gcc is more comfortable with, so I'm removing the patch. I've replaced it with an ebuild that sets the -fno-strict-aliasing flag instead.
(In reply to comment #4) > Reading the gcc manual and the code, I think this is a case where masking the > warning is the right thing. They are using a union to save memory, setting an > enumeration to set which union member was written to, etc. In other words, all > the things you do to try to simulate C++ polymorphism in C. That's not what the warning is about. If you look at the first hunk, referring to a->desc, that's declared in sane_net.h as typedef struct { SANE_Word num_options; SANE_Option_Descriptor **desc; } SANE_Option_Descriptor_Array; A SANE_Option_Descriptor ** is not a void *, and you cannot access it as if it were. Reading from and writing to *(void **) &a->desc means about as much as reading from *(long **) &i, where i is an int: it makes no sense on some systems if they are represented differently, because of that it's just plain not allowed by C, and because of that gcc will optimise on the assumption that you don't do that. > However, it is upstream's job to decide if they want to mask the warning or > write code that gcc is more comfortable with, so I'm removing the patch. I've > replaced it with an ebuild that sets the -fno-strict-aliasing flag instead. Thank you. -fno-strict-aliasing is one of the right possible answers here.
Since this seems to be more a potential problem than real breakage I have fixed it silently for all current ebuilds. Thanks guys!