DETROIT — GM posted a profit of $865 million in the first quarter, its first quarterly profits since 2007, and then promptly lost the money gambling at the Motor City casino near downtown Detroit.