Gross domestic product rebounded in the spring after contracting at the start of the year, but consumer spending remained weak.