This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/21605] declare strtol pure
- From: "msebor at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 16 Jun 2017 18:34:56 +0000
- Subject: [Bug libc/21605] declare strtol pure
- Auto-submitted: auto-generated
- References: <bug-21605-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=21605
--- Comment #5 from Martin Sebor <msebor at gmail dot com> ---
Thanks. The only thing I could think of was something like:
int i = strtol (s, 0, 0);
int *perr = &errno;
int j = strtol (s, 0, 0);
if (*perr) abort ();
but I'm not sure accessing errno like this is meant to be valid (though it
wouldn't terribly surprise me if code like that did exist).
POSIX also specifies that "the value of errno should only be examined when it
is indicated to be valid by a function’s return value" but, unfortunately, it's
not a hard requirement and C doesn't say anything like that.
It's too bad that it can't be done. Since these examples are likely rare
corner cases it might be worth seeing if the specs (i.e., C2X and POSIX) could
be tightened up to allow it.
--
You are receiving this mail because:
You are on the CC list for the bug.