MISRA C ++

编程入门 行业动态 更新时间:2024-10-26 20:35:06
本文介绍了MISRA C ++-2008规则5-0-15-数组索引应是指针算术的唯一形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要一个在MISRA方面拥有更多经验的人来帮助我解决这个问题.我有以下代码:

I need someone who has more experience with MISRA to help me to solve this. I have the following code:

byte* buf = new(std::nothrow) byte[bufferSize]; ..... for (uint32_t i = 0; i < bufferSize; i+=4) { .............. { buf[ i+0 ] = b; buf[ i+1 ] = g; buf[ i+2 ] = r; (1) Event misra_violation: [Required] MISRA C++-2008 Rule 5-0-15 violation: Array indexing shall be the only form of pointer arithmetic. buf[ i+3 ] = a; }

MISRA规则5-0-15也不允许使用ptr ++或ptr--.

MISRA Rule 5-0-15 doesn't allow also ptr++ or ptr--. What should be the approach here to increment/decrement and assign values using pointers created by new?

我的MISRA检查器是Coverity 7.0.3.3.

My MISRA checker is Coverity 7.0.3.3.

推荐答案

您的代码没有问题.它根据需要使用数组索引.您的静态分析仪已损坏.

There is no problem with your code. It uses array indexing as required. Your static analyser is broken.

更多推荐

MISRA C ++

本文发布于:2023-07-30 14:10:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250149.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MISRA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!