From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2391 invoked by alias); 1 Oct 2014 14:46:05 -0000 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 Received: (qmail 2336 invoked by uid 48); 1 Oct 2014 14:45:57 -0000 From: "dcb314 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/63431] New: implicit conversion changes value but no warning ? Date: Wed, 01 Oct 2014 14:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dcb314 at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg00051.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63431 Bug ID: 63431 Summary: implicit conversion changes value but no warning ? Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dcb314 at hotmail dot com Given C++ source code extern void g(int); void f(int p1) { int i; if (p1 >= 0) i = 0.01; else i = -0.02; g(i); } trunk 20141001 says nothing, even with provocation: $ ~/gcc/results/bin/g++ -c -O2 -Wall -Wextra oct1a.cc $ Here is clang being a bit more helpful: $ clang++ -c -O2 -Wall -Wextra oct1a.cc oct1a.cc:9:7: warning: implicit conversion from 'double' to 'int' changes value from 0.01 to 0 [-Wliteral-conversion] i = 0.01; ~ ^~~~ oct1a.cc:11:8: warning: implicit conversion from 'double' to 'int' changes value from 0.02 to 0 [-Wliteral-conversion] i = -0.02; ~ ^~~~ 2 warnings generated. $ There are half a dozen examples of this in Fedora's current Linux source code.