Hacker News new | past | comments | ask | show | jobs | submit login

How long does it take? I'm at about 20 years and still haven't made it.



Well I see it more like it takes e^-x years i.e. it never converges on total non-idiocy but you can get pretty close.

(been doing it for 17 years)


For nearly all of the last 10 years, I have been working on the specific topic of how to better predict what a C program can do (and in particular, correctly predict that a C program will behave well). This is a shorter time than 17 years, but it is more focused than using C as a tool for actually achieving something else, where you aren't thinking about the specifics of C most of the time, hopefully.

Despite this, a fortnight ago I was caught off-guard by GCC 4.9's choice of compiling the program in http://pastebin.com/raw.php?i=fRbGfQ6p to an executable that displays “p is non-null” followed by “p:(nil)”.

There has to be a way out of this. Seriously. Most C programmers neither asked for nor deserve this.


If you don't mind me taking a guess, is it because calling memcpy with NULL is undefined-behavior, thus GCC assumes p must be non-null and thus the if (p) is redundant and x must equal 1?


Exactly. Propagating the information that p was passed as argument to memcpy and thus must be non-null is a new GCC 4.9 optimization (some discussion here: http://stackoverflow.com/questions/5243012/is-it-guaranteed-... ).




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

Search: