From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 618703858422; Tue, 7 Mar 2023 16:50:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 618703858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678207814; bh=bxRXF/pWylAfMnplei5H2dmAmC7wGY0hyYWUnpLoVEM=; h=From:To:Subject:Date:From; b=F1hdI8CtQ7LSuFucXt9AD6SAC4vKbQyDRq3LK2XUcy2CBEVC95f8MKwpE67AgfLCt KHhox5qtDUprDGrz+oL5yYKjx8luZbP4FWoQ99dubRHLVDObxSp8sO2xaiHT4ejw5G yKcj5hlLGU6r2QTG61rBdM+eYlx/HJycAXTiD2U8= From: "dcb314 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109056] New: cppcheck: no warning for suspicious return type Date: Tue, 07 Mar 2023 16:50:14 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dcb314 at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109056 Bug ID: 109056 Summary: cppcheck: no warning for suspicious return type Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: dcb314 at hotmail dot com Target Milestone: --- For the following C code: unsigned long f( int n) { return n * 1000; } where the programmer may have intended using an unsigned long constant like 1000UL, then static analyser cppcheck can be made to say: mar7b.cc:4:2: style: int result is returned as long value. If the return va= lue is long to avoid loss of information, then you have loss of information. [truncLongCastReturn] return n * 1000; gcc says nothing: $ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra mar7b.cc $=20 The example code is derived from 10 examples in the source code of linux-6.3-rc1, so the problem does really occur in practice.=