![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Reading this book: https://www.oreilly.com/library/view/programming-rust/9781491927274/ch01.html
It says:
Consider the following C program:
According to C99, because this program accesses an element off the end of the array a
, its behavior is undefined, meaning that it can do anything whatsoever. When we ran this program on Jim’s laptop, it produced the following output:
Then it crashed. Jim’s laptop doesn’t even have a .netrc file. If you try it yourself, it will probably do something entirely different.
no subject
Date: 2019-09-17 05:20 am (UTC)"Hardly a week goes by at BUGSENG without having to explain to someone that almost any piece of C text, considered in isolation, means absolutely nothing. The belief that C text has meaning in itself is so common, also among seasoned C practitioners, that I thought writing a short paper on the subject was a good time investment. The problem is due to the fact that the semantics of the C programming language is not fully defined: non-definite behavior, predefined macros, different library implementations, peculiarities of the translation process, . . . : all these contribute to the fact that no meaning can be assigned to source code unless full details about the build are available. The paper starts with an exercise that admits a solution. The existence of this solution will hopefully convince anyone that, in general, unless the toolchain and the build procedure are fully known, no meaning can be assigned to any nontrivial piece of C code."
no subject
Date: 2019-09-17 05:30 am (UTC)And of course unsigned/signed chars are involved. It was the reason why people at Borland really wanted to hire me, since I knew those dirty tricks with "signed chars".