Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The author is wrong about the details but right regarding the general point. Wrongness:

1. C99 has the restrict keyword to declare no aliasing.

2. there are still many places dropping down to assembly is better than what your compiler can do, mostly since C is too portable to provide access to processor flags directly (see strlen.s/asm for your platform for an example, e.g. http://lxr.free-electrons.com/source/arch/arm64/lib/strlen.S ).

3. (nitpick) Arrays are actually types distinct from pointers in C/++ (e.g. char a[5]; char * b="asdf"; a=b; will not compile, and arrays aren't interchangeable with const-value pointers like char * const either - try passing a pointer to a function accepting an array).

edit: spacing, fixed italics instead of pointers



3. nitpick to the nitpick: your example is a bad way to prove that arrays and pointers are distinct: a = a; // also doesn't compile const int x, y; x=y; // also doesn't compile :) The following is more helpful I think: a=b; //error b=a; //fine! sizeof a != sizeof b; // true




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: