public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/109056] New: cppcheck: no warning for suspicious return type @ 2023-03-07 16:50 dcb314 at hotmail dot com 2023-03-07 16:56 ` [Bug c/109056] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: dcb314 at hotmail dot com @ 2023-03-07 16:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109056 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 value 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 $ 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/109056] cppcheck: no warning for suspicious return type 2023-03-07 16:50 [Bug c/109056] New: cppcheck: no warning for suspicious return type dcb314 at hotmail dot com @ 2023-03-07 16:56 ` pinskia at gcc dot gnu.org 2023-03-07 16:56 ` pinskia at gcc dot gnu.org 2023-03-07 17:03 ` dcb314 at hotmail dot com 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-07 16:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109056 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- -Wconversion is needed for this warning in GCC. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/109056] cppcheck: no warning for suspicious return type 2023-03-07 16:50 [Bug c/109056] New: cppcheck: no warning for suspicious return type dcb314 at hotmail dot com 2023-03-07 16:56 ` [Bug c/109056] " pinskia at gcc dot gnu.org @ 2023-03-07 16:56 ` pinskia at gcc dot gnu.org 2023-03-07 17:03 ` dcb314 at hotmail dot com 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-07 16:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109056 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > -Wconversion is needed for this warning in GCC. Which turns on -Wsign-conversion . ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/109056] cppcheck: no warning for suspicious return type 2023-03-07 16:50 [Bug c/109056] New: cppcheck: no warning for suspicious return type dcb314 at hotmail dot com 2023-03-07 16:56 ` [Bug c/109056] " pinskia at gcc dot gnu.org 2023-03-07 16:56 ` pinskia at gcc dot gnu.org @ 2023-03-07 17:03 ` dcb314 at hotmail dot com 2 siblings, 0 replies; 4+ messages in thread From: dcb314 at hotmail dot com @ 2023-03-07 17:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109056 --- Comment #3 from David Binderman <dcb314 at hotmail dot com> --- (In reply to Andrew Pinski from comment #2) > Which turns on -Wsign-conversion . -Wsign-conversion seems close, but not quite right. The problem is in potential overflow, not sign conversion. -Woverflow doesn't seem to do anything. Nor does -Wconversion. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-07 17:03 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-07 16:50 [Bug c/109056] New: cppcheck: no warning for suspicious return type dcb314 at hotmail dot com 2023-03-07 16:56 ` [Bug c/109056] " pinskia at gcc dot gnu.org 2023-03-07 16:56 ` pinskia at gcc dot gnu.org 2023-03-07 17:03 ` dcb314 at hotmail dot com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).