C & undefined behaviour - was Re: tumble under BSD
toby at telegraphics.com.au
Sat Apr 2 16:36:40 CDT 2016
On 2016-04-02 5:22 PM, Paul Koning wrote:
>> On Apr 2, 2016, at 5:09 PM, Mouse <mouse at Rodents-Montreal.ORG> wrote:
>>> It appears that the stdio that I'm linking against on OS X 10.9.5
>>> does not keep the file pointers synchronized between the system and
>> Actually, I would say that any supposedly-portable software that
>> depends on either behaviour is broken; AFAICT stdio has never promised
>> either way.
>> I'd say it's about as important to know what is _promised_ as it is to
>> know what _actually happens_. This sort of thing is why.
> I wonder how clearly the various manpages state the promises.
> It's unfortunate that lots of programmers have the habit of blaming
the tool when their code breaks because they are doing "undefined"
things. There's a great paper about undefined things in C, and what
compilers may do, and the way a number of well known open source
projects react -- not by fixing the code but by turning off all manner
of optimizations instead.
Anyone interested in C and UB will want to read most of
John Regehr's http://blog.regehr.org/ - it hosts some of the best
material on UB.
More information about the cctalk