
Y U NO SEE STANDARDS!
I had to make this. There are people who give a damn to the standards and follow the stone age Turbo C 3.1 compiler, run programs compiled by it. In the cases for compiler dependent and undefined behaviours, they try to guess in some way why the output was like that and get into a conclusion.
In a forum this was a part of a conversation when I commented referring to sections to C99, that the (in)famous (i++ + ++i) was not a defined behaviour in the standards:
can u tell me y it is not a legal C Language statement ? n plz dont tell me abt all ur CXX Standard sec answers…
If u knw den specify it ?
I think the guy thought it was some kind of question answer book. I don’t know. Although in this case I think the guy Googled and got why the standard is important, after my strong reply.
It is difficult to argue, because many are reluctant to get exposed to the truth and also because I am don’t always find the exact point or the exact set of points from the standard. Even more difficult to explain why it is undefined when they can see an output in front of them and the output is same for the first n runs.
Once someone challenged me that local array can be returned from a function to the caller, and ran a sample code which initialized, in a function foo, a local array with some dummy value and return it to main to print it. Compiled in Turbo C. Executed it and showed me that the same initialized values were there in the main. It was around 30 minutes we shouted on each other and at last made him understand why it is not the case.
Another myth which I came around was the “implicit return” value from the function. The point was, even if you do not return a value from a function in C, the last calculated value is automatically returned to the caller. Therefore doing something like this int x = foo () will get the value last computed inside foo will be “implicitly returned” to the caller and assigned to x. This came with a demo code, again, with Turbo C. There are a lot of other myths.
Yet another problem. If anyone understands the importance of the standard, they try to learn the C Language from the standard itself, and it is again very difficult to make them understand why they should not learn C from standards. Although after 2 ~ 3 days trying to learn C from the standard document they themselves come to know why it is not a good idea.
On the positive side is that a lot of people are also coming out of the myths and learning to use the standard, which required a lot of effort for me when I got a copy (equivalent) from http://www.open-std.org/. I believe things will get better.