In the past two years, the unpaid bill for a budget category known as "other post-employment benefits" rose by 12 percent, to $554 billion. Most of that represents health-care benefits for retirees.

Increases like that are "unsustainable," S&P said in its report.

The report is based on 2015 figures, the latest available, which don't reflect cost improvements some states have seen.

"Nevertheless," the report said, "the growth in total state OPEB liabilities underscores the magnitude of liability growth states can experience over a short period of time."

Many state governments have given health-care benefits a lower funding priority than pension funds because, unlike pension payments, they are not protected by state constitutions.

Those protections mean that the bill for underfunded pensions will eventually come due, even in states where retirement plans have been cut back or eliminated for new workers.

But most states lost ground in fiscal 2015, according to S&P, in part because their investment returns came up short.

"After losses in 2008 and 2009, most U.S. state pension plans have not been able to recover to funded levels seen in the early 2000s," S&P said. "Investment returns in 2015 and 2016 are not going to make that path any easier."