When I last worked in a supermarket (just over three years ago) taking home or giving away food that was destined for the bin was treated as theft. You could be fired for it if your manager felt that way inclined.
Several months before I started, several people at another store lost their jobs for just that. Instead of throwing out the bake-goods, they'd been giving them out in small amounts to people who were struggling.
Sometimes it was a handful of bread-rolls, other times it would be croissants or muffins. There was no loss to the company because the food had been written off anyway. Still -- it was treated as theft, and they were fired. The company would prefer the food was wasted than it feed people.
I'm not saying these issues are more important than keeping people fed, but I do think addressing these sorts of things would go a long way to make policies allowing food to be given away more practical.
Pretty sure the liability thing is just a convenient excuse. In the US we have the Bill Emerson Good Samaritan Food Donation Act, which protects food donors from being sued. I bet most other countries have something similar. Additionaly, nobody has ever been sued over donated food in the US.
http://www.nzwc.ca/focus/food/guidelines-for-food-donations/...
In that case, I don't follow supermarkets' logic. If donations are restricted to people who can't otherwise afford the food, and the food will be discarded anyway, why not donate it? Maybe some people will substitute donated food in place of purchasing food themselves. I wonder if supermarkets have data suggesting this is a meaningful fraction of customers.
As another poster said, no one has been sued in the US for donations, but supermarket chains are also reticent about the optics of donating food that has clearly expired. Just because you won't be sued doesn't mean you won't feel some blowback in public sentiment if you cause an outbreak of food poisoning in the food-insecure demographic of the population by improperly donating food.
The pantries I work with collect and redistribute food from something like 30 different local businesses and organizations, including local supermarkets (mostly "day-old" bread and pastries), cafeterias (surplus prepared food), and farmers (surplus produce). We also benefit from middle-man organizations that collect at a larger scale and redistribute to smaller pantries like us -- large donations of canned and other packaged food, gleaned fruits and vegetables which are perfectly fine but didn't make the market cut (ie, ugly tomatoes), and the like.