A Guide to Undefined Behavior in C and C++

Bumped into this nice article by John Regehr about undefined behaviour in C and C++. The article is in three parts:

  1. A Guide to Undefined Behavior in C and C++ Part 1
  2. A Guide to Undefined Behavior in C and C++ Part 2
  3. A Guide to Undefined Behavior in C and C++ Part 3


Programming languages typically make a distinction between normal program actions and erroneous actions. For Turing-complete languages we cannot reliably decide offline whether a program has the potential to execute an error; we have to just run it and see.

In a safe programming language, errors are trapped as they happen. Java, for example, is largely safe via its exception system. In an unsafeprogramming language, errors are not trapped. Rather, after executing an erroneous operation the program keeps going, but in a silently faulty way that may have observable consequences later on. Luca Cardelli’s article on type systems has a nice clear introduction to these issues. C and C++ are unsafe in a strong sense: executing an erroneous operation causes the entire program to be meaningless, as opposed to just the erroneous operation having an unpredictable result. In these languages erroneous operations are said to have undefined behavior.

(more…)

Putting Applications back in dock..

Every time I mess up with my Mac and re-install, I miss my applications folder in dock. If you are also running into this issue then it’s quite easy to get it in dock. All you have to do is to go to your Macintosh HD (or where-ever you have installed Mac OS X) locate Applications folder and just drag it down to dock.

Adding Applications folder to Dock

Parallel Computing

Parallel computing is a form of computation in which many calculations are carried out simultaneously, operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently (“in parallel”). There are several different forms of parallel computing: bit-level, instruction level, data, and task parallelism. Parallelism has been employed for many years, mainly in high-performance computing, but interest in it has grown lately due to the physical constraints preventing frequency scaling. As power consumption (and consequently heat generation) by computers has become a concern in recent years, parallel computing has become the dominant paradigm in computer architecture, mainly in the form of multicore processors.

Parallelism can be broadly classified in three types:

  1. Instruction-level
  2. Data Parallel
  3. Task Parallel

(more…)

ISO Updates C Standard

The International Organization for Standardization (ISO) has published the new specifications for the C programming language. The standard has been known unofficially as C1X and was published officially as ISO/IEC 9899:2011. The standard, now referred to informally as C11, provides greater compatibility with the C++ language and adds new features to C (as indicated in the draft).

Those features include multi-threading, Unicode support based on the ISO/IEC TR 19769:2004 specification, additional macros for querying the characteristics of floating point types and the ability to use static assertions. The recently released revision also standardises many of the features that current compilers already support, as required by the draft.

The path of the specification through the standardisation process was uneventful. The ISO’s Information Technology Task Force (ITTF) waved the standard through without further comment and the Final Draft Review was also accepted last October without any new comments. The standard is based on theN1570 draft passed in April 2011.