News for hackers. Stuff that matters.
Re:GCC undefined behaviors are getting wild by gpderetta on Monday November 28, 2022 @08:55AM (#33773661)
The contract is that libX_foo can return null. But a specific implementation might not. Now you need to remove the caller side check to shut up the compiler which will leave you exposed to a future update making full use of the contract.

Also consider code that call libX_foo via a pointer. After specialization the compiler might see that the check is redundant, but you can't remove the check because the function might still be called with other function pointers making full use of the contract.

Re:GCC undefined behaviors are getting wild by xigoi on Monday November 28, 2022 @09:08AM (#33773781)
> The contract is that libX_foo can return null.

I'd expect any reasonable library to say “libX_foo returns null if [something happens]”. What use is there in a procedure that can just return null whenever it feels like it?

Re:GCC undefined behaviors are getting wild by account42 on Tuesday November 29, 2022 @04:20AM (#33785374)
It returns null when it fails to do its task for some reason. It is not unreasonable for the condition for that failure to be complex enough or change over time so it doesn't make sense to spell it out in the interface contract.