https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888
--- Comment #48 from M Welinder <terra at gnome dot org> ---
It's your (1). gcc is changing a program that can rely on errno not being
changed to one where the C library can change it. (The current C library or
any future library that the resulting binary may be dynamically linked
against.)
Consider code like this
fd = open(filename, ...);
if (fd < 0) {
fprintf(stderr, "%*s: %s\n",
MIN(20, mystrlen (filename)), ;
filename,
strerror(errno));
...;
}
If the C library is in a bad mood you will print the wrong error message.
strlen isn't the obvious candidate for a C library function changing errno, but
I can see an instrumented library do it.
Is there any real-world situation that benefits from introducing these calls?
It has the feel of optimizing for a benchmark.