Roman Ostriakov, a 30-year-old Ukrainian living rough in Italy, is on his way to becoming an international cause celebre, or at least a meme. Translated into numerous languages, his story has been in the media and on social networks since Monday, when a court of appeals in Genoa annulled his 2013 conviction for stealing 4.07 euros ($4.68) of cheese and sausage from a supermarket. The court said the food had been taken "out of an immediate and vital need for nourishment."

Italy is not a common-law country and the ruling does not constitute a precedent. The probable legal basis for the court's decision is the principle "ad impossibilia nemo tenetur" (no one can be forced to do the impossible), proposed by Roman jurist Publius Iuventius Celsus a little less than 2,000 years ago. It is used only in exceptional cases, to void normally valid rules when there is no way they can be followed. In other words, Italians won't now be allowed to steal food if they're hungry.

Judicial lenience in cases of extreme need is neither unique nor limited to Italy. Last year, a British magistrate discharged Paul and Kerry Barker, who were caught stealing food after a confluence of dire circumstances left them with just 8 pounds ($11.58) a week to live on. "How are they expected to live?" the judge asked.

Many such cases never make it to court. In Tarrant, Alabama, in 2104, a police officer summoned by supermarket guards bought a dozen eggs for a destitute woman named Helen Johnson after the eggs she was trying to steal broke in her pocket. The policeman and his colleagues then delivered enough food to her house to feed her family through Christmas.

It is more common, however, for penniless people who steal food to be punished. Ostriakov's release from a six-month prison sentence and 100-euro fine is noteworthy, because it shows that developed nations' poverty-alleviating systems don't quite work. The cases of Ostriakov, the Barkers and Johnson were "clean" enough to induce pity. The Ukrainian hid the stolen items in his clothing and didn't resist when another customer reported him to supermarket security. The theft was also small enough for it to be clear he was just desperate. The Barkers were both unemployed -- she because of pancreatitis and clinical depression, he after a spinal injury -- and they were stealing from bins of discarded, expired food at a Tesco supermarket that the store still saw fit to guard. Johnson's $120 check, on which her family subsisted, had gotten lost in the mail, leaving her penniless.

Yet a 30-year-old, homeless, disturbed Frenchman who tried to walk away with 37 euros' worth of food, after the supermarket cashier had tried to stop him, was sentenced to a month in prison, with seven more months suspended. In Waco, Texas, Willie Smith Ward, a man with multiple previous convictions, was sentenced to 50 years in prison for stealing a $35 rack of pork ribs. He had told the supermarket employee who caught him, "I got a knife" (he didn't really have one).

Sometimes, people with no such aggravating circumstances don't get as lucky as Ostriakov or the Barkers. In a column for the Guardian, an Englishman, Darren Head, told of pocketing a sandwich at a supermarket while homeless and hungry. He said he was fined 80 pounds and spent a week in prison for being unable to pay.

According to the 2015 United Nations Food and Agriculture Organization report on food insecurity, 15 million people in the developed world are undernourished. There were 20 million in 1992, but the number is still staggering: 1.8 percent of the wealthy countries' population.

These nations have extensive social safety networks, including dozens of means-tested programs to alleviate poverty and thousands of private charities. They also have more food than they can eat. Activists at the U.S. Natural Resource Defense Council say 40 percent of food sold in the U.S. never gets eaten, because of overzealous "use by," "sell by" and "display until" labeling and the inefficiency of supermarket chains. That isn't far off the UN's estimate of 30 percent wastage globally. Tesco, from which the Barkers were caught stealing, was recently throwing away 60,000 metric tons of food a year, a number the company has vowed to cut.

Because of inefficiency and overregulation, too many poor people are denied the aid they need to keep minimal dignity. A tiny check gets lost in the mail. An ex-convict is treated with suspicion and sent on a bureaucratic wild goose chase. A man's benefits are cut because he's too hungry to think clearly and make it to an appointment. Illness, addiction, depression, poor education and the lack of appropriate paperwork make it difficult for poor people to navigate the social security thickets.

Also because of inefficiency and overregulation, hundreds of billions of dollars' worth of food gets wasted and the remainder is often too expensive for the poorest people to buy.

Governments can fix both problems. A universal basic income, which several nations are studying now, would radically simplify welfare systems, providing everyone with a basic subsistence level, no questions asked. It would make exceptions like the ones made for Ostriakov and the Barkers unnecessary. The basic charitable impulses are there, as the Italian court has shown; all that is lacking is the will to turn random acts of kindness into policy.

- Leonid Bershidsky, a Bloomberg View contributor, is a Berlin-based writer.