https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118326
Bug ID: 118326
Summary: time_t conversion warnings wanted
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gccbmw at lsmod dot de
CC: dmalcolm at gcc dot gnu.org, rguenth at gcc dot gnu.org
Target Milestone: ---
Old bug 96570 was about time_t => int conversions, that could already be
covered by -Wconversion
But this issue is about int => time_t conversions. It probably needs a new way
to tell gcc, that anything that goes into time_t should be able to hold more
than the 31 bits of a signed int, because that would overflow soon (in 2038)
and will cause trouble.
Richard Biener suggested, -fanalyzer could do that.
The new warning should trigger on
foo = gmtime(someint)
time_t t = atoi(somestring)
time_t t = atol(somestring)
time_t t = ntohl(int)
This feature would also be useful to warn about int => size_t conversions.