U.S. markets posted gains on Thursday despite a Commerce Department report that second-quarter economic growth numbers fell short of analysts’ expectations.