News for hackers. Stuff that matters.
Re:Who Says C is Simple? by pcwalton on Wednesday July 17, 2013 @02:33PM (#6059341)
But the article contains many examples of the compiler doing things behind your back. For example:

> The answer depends on whether the optimizations are turned on. If they are then the answer is 3 (the first definition is inlined at all occurrences until the second definition). If the optimizations are off, then the first definition is ignore (treated like a prototype) and the answer is 4.

Re:Who Says C is Simple? by dietrichepp on Wednesday July 17, 2013 @02:35PM (#6059362)
In that case, it's your fault for defining two versions of a function (inline and non-inline) that do different things.
Re:Who Says C is Simple? by anon1385 on Wednesday July 17, 2013 @03:09PM (#6059575)
Even if you don't do something like that a modern C compiler will do all sorts of things behind your back. Like removing null checks[1] or pointer overflow checks[2]

[1] http://www.cvedetails.com/cve/CVE-2009-1897

[2] http://www.cvedetails.com/cve/CVE-2008-1685

Re:Who Says C is Simple? by rapala on Thursday July 18, 2013 @05:13AM (#6062579)
Well, to be fair, the NULL check was in a wrong place. The pointer was already dereferenced before the check.

  struct tun_struct *tun = __tun_get(tfile);
  struct sock *sk = tun->sk;
  unsigned int mask = 0;
  
  if (!tun)
    return POLLERR;