Stocks erased gains and the S&P 500 and the Nasdaq turned negative on Wednesday as shares in the materials sector fell sharply as uncertainty over Europe's debt crisis continued to dog the market.

The Dow Jones industrial average edged up 14.91 points, or 0.13 percent, to 11,205.60. The S&P 500 dropped 3.58 points, or 0.30 percent, to 1,171.80. The Nasdaq Composite lost 7.60 points, or 0.30 percent, to 2,539.23.