What problem arrise when we have union + volatile?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello all,
I have the following .c file:
typedef unsigned char U8;
typedef unsigned int U16;
union twoBytesUnion{
U16 a;
};
union twoBytesUnion var_AA;
volatile union twoBytesUnion var_BB;
volatile U16 var_CC;
U16 var_temp;
void main (void)
{
var_CC = 0;
var_temp = var_CC; // Green check - NIV
var_AA.a = 0;
var_temp = var_AA.a; // Green check - NIV
var_BB.a = 0;
var_temp = var_BB.a; // Orange check - NIV -> *Why? What problem arrise when we have union + volatile?*
}
Polyspace settings: "Ignore default initialization of global variables" - checked Char: 8bits Int: 16bits Alignment: 8bits.
The Polyspace says that the orange check "Variable var_BB that is declared volatile may lead to imprecise check". Why?
댓글 수: 0
답변 (1개)
Alexandre De Barros
2015년 4월 3일
Hi Cristina,
It is indeed an imprecision when a volatile union is used. It has been reported and should be fixed in a future version.
So for the moment you can simply ignore it.
Best regards,
Alexandre
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Options at Command Line Only에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!