On Wed, Jan 13, 2016 at 3:21 PM, John Spencer
<[email protected]> wrote:
> the following ISO C conforming program is broken on latest OpenBSD:
>
> #include <stdio.h>
> int close() { puts("XXX"); return 0;}
> int main() { fclose(stdout); return 0;}
>
> the program is expected to not produce any output, however on OpenBSD it
> prints "XXX".
> this bug affects real-world programs [0].

But is this really an OpenBSD bug?

close() is defined in IEEE Std 1003.1-1988. The above definition of
close does not conform to that standard.

(Also, OpenBSD's man page for fclose explicitly mentions close(2) and
also suggests that errors in close(2) will be errors in fclose(3)
which should be a strong hint about this issue.)

I totally get the idea of using _ prefixed names for internal use by
the compiler and libc, and I do wonder why that's not happening here.
I guess what I'm asking is whether that practice has been incorporated
into some standard, mutilated by some standard, or simply assumed to
be the case and thus ignored by all relevant standards.

Thanks,

-- 
Raul

Reply via email to