From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22954 invoked by alias); 4 Jan 2013 17:53:20 -0000 Received: (qmail 22904 invoked by uid 48); 4 Jan 2013 17:53:02 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/39170] provide an option to silence -Wconversion warnings for bit-fields Date: Fri, 04 Jan 2013 17:53:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00341.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D39170 --- Comment #13 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez 2013-01-04 17:53:00 UTC --- (In reply to comment #12) > Is there any resolution to this issue? We need to move to a more recent v= ersion > of gcc, but are still stuck at gcc 4.2.4.=20 I think the best option would be to have a GCC extension for casting bit-fi= eld types (int:2) so they can be used to silence false positives. But this may = be rejected by the C/C++ FE maintainers, so unless you get their approval, I wouldn't try to pursue it. The second best option, and probably easier to implement, is to have a new option -Wconversion-bitfields that gives the Wconversion warning for bitfie= lds and use that to control the warning code like: if (unsafe_conversion_p (type, expr, true)) warning_at (loc, TYPE_IS_BITFIELD(type) ? OPT_Wconversion_bitfield : OPT_Wconversion, "conversion to %qT alters %qT constant value", type, expr_type); return; I don't even know if TYPE_IS_BITFIELD exists or there is an equivalent API. Personally, I have no free time to work on this, so someone else will have = to do it. I can give some hints on what you would need to do to implement it if someone is interested and needs guidance.