[Bug c++/39089] New: -Wconversion is buggy with bitwise operators
g++ 4.3.3 emits warnings for every statement in the following function when the code is built this way: /gcc43/bin/g++ -c -Wall -Wconversion test.cpp void func(unsigned char a, unsigned char b, unsigned char *out) { *out = a | b; *out = out[0] & 0x20; out[0] &= 0x20; } I'd expect bitwise operators to see/preserve argument widths... -- Summary: -Wconversion is buggy with bitwise operators Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: oleg dot smolsky at riverbed dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39089
[Bug c++/39089] -Wconversion is buggy with bitwise operators
--- Comment #1 from oleg dot smolsky at riverbed dot com 2009-02-03 17:58 --- Created an attachment (id=17238) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17238&action=view) The test case -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39089
[Bug c++/39089] -Wconversion is buggy with bitwise operators
--- Comment #6 from oleg dot smolsky at riverbed dot com 2009-02-03 22:23 --- Created an attachment (id=17239) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17239&action=view) The fix from gcc4.4 This is the naive fix merged from the trunk. Fixes two out of three warnings in C++ mode. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39089
[Bug c++/39089] -Wconversion is buggy with bitwise operators
--- Comment #5 from oleg dot smolsky at riverbed dot com 2009-02-03 21:13 --- I've just built gcc 4.4 and it emits no warnings for the test case above. Is there any chance the fix could be back-ported into 4.3? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39089
[Bug c++/38522] g++ -Wconversion warnings
--- Comment #3 from oleg dot smolsky at riverbed dot com 2009-03-03 19:40 --- I've just built gcc from the official SVN and it looks like this bug is not fully fixed. The following code generates a warning when compiled with -Wconversion: #include #define M10xC0u #define M20x20u unsigned char test(unsigned char a1, unsigned char a2) { unsigned char local = (a1 & M1) | (a2 & M2); // warn return local; } Could someone re-open the bug please? -- oleg dot smolsky at riverbed dot com changed: What|Removed |Added CC||gcc at gaul dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38522
[Bug c++/38522] g++ -Wconversion warnings
--- Comment #5 from oleg dot smolsky at riverbed dot com 2009-03-03 22:24 --- BTW, my comment was about the C++ frontend. IE: .../gcc44/bin/g++ -c -Wall -W -Wconversion test.cpp -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38522