Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Comment Re:Wait, what? (Score 1) 391

Why the fuck doesn't slashdot has an edit option.
Ignore the second post, it is complete bullshit.

In the first post, replace the second-to-last paragraph by:
If however offset is non NULL, then tun might or might not be NULL, and the test might be reached. It therefore must be preserved.

Then add at the end of the post, by test I mean both the if and its body.

Comment Re:Wait, what? (Score 1) 391

I'd like to make the last paragraph more precise,

If sk is not the first member of tun, the compiler can remove the if (since the condition is always true), but it must preserve the body of the if. If it doesn't keep the body, it is a bug.

On the other hand, if sk is the first member of tun, the compiler can remove the if and its body.

Comment Re:Wait, what? (Score 1) 391

You are correct in saying that it is tun + offset which is dereferenced (not tun itself).

(BTW tun is obviously a pointer in the code given, no need to take its address.)

That means that the compiler knows, if it reaches the if, that tun+offset is not NULL, but not necessarily that tun is not NULL.

That would be true in general. But what everyone here seems to have missed, is that offset is known at compile time.

If offset is NULL, then either tun is NULL and we enter the realm of undefined behavior and the compiler is permitted to remove the check, or tune is not NULL in which case the test is dead code.

If however offset is non NULL, then tun must be non NULL if the test is reached.

To summarize, if sk is the first member of tun (offset zero), then the compiler has all rights to remove the test. If not, this is a compiler bug.

Slashdot Top Deals

What is research but a blind date with knowledge? -- Will Harvey

Working...