Share via


컴파일러 경고(수준 3) CS0675

업데이트: 2007년 11월

오류 메시지

부호 확장 피연산자에 비트 논리 OR 연산자를 사용했습니다. 더 작은 부호 없는 형식으로 먼저 캐스팅하십시오.
Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first

컴파일러가 암시적으로 변수의 범위를 넓히고 부호 확장한 다음 결과값을 비트 논리 OR 연산에 사용했습니다. 이는 예기치 않은 결과를 불러올 수 있습니다.

다음 샘플에서는 CS0675 오류가 발생하는 경우를 보여 줍니다.

// CS0675.cs
// compile with: /W:3
using System;

public class sign
{
   public static void Main()
   {
      int hi = 1;
      int lo = 1;
      long value = (((long)hi) << 32) | lo;              // CS0675
      // try the following line instead
      // long value = (((long)hi) << 32) | ((uint)lo);   // correct
   }
}