EVA插件:如何通过temp变量检查“temp =(volatile unsigned short *)add”中的添加值

问题描述 投票:0回答:1

我试图通过以下示例中的temp变量检查“temp =(volatile unsigned short *)add”中的添加值:

main() {
    unsigned short add = 0x01;
    unsigned short val = 0x00;
    unsigned short *temp;
    temp = (volatile unsigned short*) add;
    *temp = val;
    //@ assert &temp == (unsigned short) 0x01;
}

但我在“// @ assert&temp ==(unsigned short)0x01”这一行得到了这个错误。“

[kernel] user error: incompatible types unsigned short and unsigned short **
[kernel] user error: stopping on file "test_func_call.c" that has errors. Add '-kernel-msg-key pp'for preprocessing command.

我知道这可能与C有关,但我也使用Frama-C的标签。希望我能收到关于通过Frama-C检查添加值的答案。

c frama-c
1个回答
1
投票

关于:

assert &temp == (unsigned short) 0x01;  

这是试图将temp(在堆栈上)的地址与某个地址(堆栈上的该位置除外)进行比较。自然地,assert()被触发

访问内存中特定地址内容的正确方法是:

temp =  *(unsigned short *) 0x01;
© www.soinside.com 2019 - 2024. All rights reserved.