On Thu, 14 Jan 2016, Raul Miller wrote:
> 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?

Yes, it is: OpenBSD strives to provide not just a POSIX environment but 
also a conforming ISO C environment**.  In ISO C, close() is in the 
application namespace so a program must be able to define its own version 
and fclose() must *NOT* invoke that version.

...
> 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.

Making libpthread work makes the obvious thing wrong.


> 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.

I think the relevant standard for this case is ELF.


Philip Guenther

** blah blah exceptions for stuff like rand() blah blah

Reply via email to