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

Of course there is no UB in the source code. That makes the problem worse, not less bad... Non-nullness is inferred from 'node->child = NULL;' which would be UB would node be NULL. At this point the compiler thinks it is superfluous to check whether 'node' is null and start to propagates that, except it messes up.

It seems that it messes up extremely badly because even -fno-delete-null-pointer-checks does not seem to fix the issue :/




> Non-nullness is inferred from 'node->child = NULL;' which would be UB would node be NULL.

There’s also a dereference inside of walk, except it’s protected by a NULL check.


Yes I see that, I was not describing what the compiler should observe to work properly, I was describing the erroneous reasoning it was making prior to the fix. I should have written: non-nullness of 'node'.

And TBH I'm starting to be more concerned by the fact that fno-omit-null-pointer-checks did not suppress that codegen bug than by its existence in the first place...


> I was describing the erroneous reasoning it was making prior to the fix. I should have written: non-nullness of 'node'.

I think you're misinterpreting the error in the compiler's reasoning: unless I am misunderstanding you, it doesn't seem to match the comment I linked earlier. The reason -fno-delete-null-pointer-checks did not help is because it only kicks in when you use a NULL pointer in a way that is undefined, but that's not what's occurring here.


> And TBH I'm starting to be more concerned by the fact that fno-omit-null-pointer-checks did not suppress that codegen bug than by its existence in the first place...

-fno-omit-null-pointer-checks doesn't suppress it because it has nothing to do with it. -fno-omit-null-pointer-checks means "don't infer from the presence of *x that x is non-NULL." In this case, the non-nullity of x was inferred directly from the check "if (x != NULL)".




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

Search: