Criticism of the C programming language: Difference between revisions

Content deleted Content added
m restore the flavor of recently deleted text, in a different setting
Mrjeff (talk | contribs)
Add section on undefined behaviour
Line 6:
 
Kernighan and Ritchie made reference to the basic [[design philosophy]] of C in their response to criticism of C not being a strongly-typed language<ref>Brian W. Kernighan and Dennis M. Ritchie: ''The C Programming Language,'' 2<sup>nd</sup> ed., [[Prentice Hall]], 1988, p. 3.</ref>: "Nevertheless, C retains the basic philosophy that programmers know what they are doing; it only requires that they state their intentions explicitly."<ref>{{cite web | author=Dennis Ritchie | url=http://cm.bell-labs.com/cm/cs/who/dmr/chist.html | title=The Development of the C Language | accessdate=2006-07-26}}</ref>
 
==Undefined behaviour==
 
Many operations in C are 'undefined behaviour'. This means that the exact behaviour which arises is not defined by the standard, and exactly what will happen does not have to be defined by the compiler. A famous expression in comp.std.c is that a compiler can cause "demons to fly out of your nose". Often in practice what happens with undefined behaviour is bugs which are hard to track down and cause memory corruption. Examples of undefined behaviour are:
 
* Accessing outside the bounds of an array.
* Overflowing a signed integer.
* Reaching the end of a function which should return a value with finding a return statement.
* Reading the value of a variable before writing to it.
 
 
==Memory allocation==