Stocks declined for a third consecutive session on August 18, led mainly by weakness in semiconductor shares that had helped drive the market’s recent rally. The S&P 500 remained near record highs, but concerns about rising Treasury yields weighed on sentiment.