Walmart’s second-quarter results are showing that United States consumers across the spectrum are still flocking to the retailer’s stores despite economic headwinds, but its shares have dipped as the company’s margins ebbed and inventory costs rose.

The world’s largest retailer has scooped up market share from rivals as wealthier consumers frequent the store more often, worried about the effects of tariffs on prices, the company’s results on Thursday showed.

That has fueled an 85 percent surge in the stock over the last year-and-a-half that some analysts say has made its valuation too lofty.

Shares were down 4 percent in midday trading in New York, as its second-quarter profit was lower than expected, registering Walmart’s first earnings miss in more than three years.

Investors also fo

See Full Page