From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4546 invoked by alias); 13 Dec 2012 11:10:02 -0000 Received: (qmail 4398 invoked by uid 48); 13 Dec 2012 11:09:44 -0000 From: "loose at astron dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55671] -Wconversion fails to warn for sign-conversion Date: Thu, 13 Dec 2012 11:10: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: normal X-Bugzilla-Who: loose at astron dot nl X-Bugzilla-Status: UNCONFIRMED 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" 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: 2012-12/txt/msg01301.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55671 --- Comment #5 from loose at astron dot nl 2012-12-13 11:09:43 UTC --- If this is by design, then the documentation is buggy. Here's a literal quote form the man page of g++ -Wconversion Warn for implicit conversions that may alter a value. This includes conversions between real and integer, like "abs (x)" when "x" is "double"; conversions between signed and unsigned, like "unsigned ui = -1"; and conversions to smaller types, like "sqrtf (M_PI)". Do not warn for explicit casts like "abs ((int) x)" and "ui = (unsigned) -1", or if the value is not changed by the conversion like in "abs (2.0)". Warnings about conversions between signed and unsigned integers can be disabled by using -Wno-sign-conversion. For C++, also warn for confusing overload resolution for user- defined conversions; and conversions that will never use a type conversion operator: conversions to "void", the same type, a base class or a reference to them. Warnings about conversions between signed and unsigned integers are disabled by default in C++ unless -Wsign-conversion is explicitly enabled. It explicitly gives the example "unsigned ui = -1" as an example. Furthermore, older g++ compilers used to give this warning. I tried it with g++ 4.1.2 and it properly gives a warning. I also find it a bit counter-intuitive that gcc *does* warn about it, whereas g++ does *not*.