相关疑难解决方法(0)

MISRA C++ 2008 规则 5-2-7 违规:具有指针类型的对象不得直接或间接转换为不相关的指针类型

在以下示例中:

void bad_function()
{  
  char_t * ptr = 0;

  // MISRA doesn't complains here, it allows cast of char* to void* pointer
  void* p2 = ptr;

  // the following 2 MISRA violations are reported in each of the casts bellow (two per code line)
  // (1) Event misra_violation:     [Required] MISRA C++-2008 Rule 5-2-7 violation: An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly
  // (1) Event misra_violation:     [Required] MISRA C++-2008 Rule …
Run Code Online (Sandbox Code Playgroud)

c++ pointers misra system-requirements

7
推荐指数
1
解决办法
6221
查看次数

标签 统计

c++ ×1

misra ×1

pointers ×1

system-requirements ×1