public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/44574] New: Avoid use of atoi
@ 2010-06-17 22:43 jsm28 at gcc dot gnu dot org
0 siblings, 0 replies; only message in thread
From: jsm28 at gcc dot gnu dot org @ 2010-06-17 22:43 UTC (permalink / raw)
To: gcc-bugs
The atoi function has undefined behavior if its argument is outside
the range of int. Thus, GCC should not use it for any user input that
might be outside that range.
For example, -O4294967296 should act like -O3, but on 64-bit systems with
glibc it acts like -O0 (glibc's atoi converts the return from strtol to int,
thereby losing high bits).
In most cases (like the above), using strtol and saturating for input out
of range of int is probably appropriate, but some cases may need errors for
large input. A helper function - like atoi, but saturating - may be
appropriate.
--
Summary: Avoid use of atoi
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jsm28 at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44574
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-17 22:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-17 22:43 [Bug other/44574] New: Avoid use of atoi jsm28 at gcc dot gnu dot org
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).