This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/44574] New: Avoid use of atoi
- From: "jsm28 at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Jun 2010 22:43:37 -0000
- Subject: [Bug other/44574] New: Avoid use of atoi
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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