News for hackers. Stuff that matters.
Re:What is your favorite C programming trick? (2009) by londons_explore on Sunday November 22, 2020 @03:05PM (#25180577)
I was about to ask if it was legal to dereference a null pointer and then take the address of it... I presume it is not, but I'm surprised compilers don't complain at compilation time.
Re:What is your favorite C programming trick? (2009) by saagarjha on Monday November 23, 2020 @03:52AM (#25184819)
Dereferencing a null pointer and then immediately "undoing" it by taking its address is actually legal, I believe. I think the undefined behavior here is the member access instead of the magic sequence &* which is supposed to cancel out.