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.