This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/21605] declare strtol pure


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]