필터 지우기
필터 지우기

Bug Finder report for autosar violation 5-0-15.

조회 수: 2 (최근 30일)
Kunal Khosla
Kunal Khosla 2021년 1월 7일
답변: Srija Kethiri 2022년 10월 28일
Hi,
I am facing a violation in a line of my C++ code, where the function is returning a pointer to a structure and i am indexing the returned pointer as below:
f(x)[0].value;
The AUTOSAR violation states the "array indexing is the only form of pointer arithmetic".
Is the reason for violation because we are returning a structure pointer inside of f(x)? and not a array pointer?
Regards
Kunal

답변 (1개)

Srija Kethiri
Srija Kethiri 2022년 10월 28일
Hi Kunal,
The reason is, structure pointer violates the following compliance rules of ANSI C:
17.1 (required): Pointer arithmetic shall only be applied to pointers that address an array or array element.
17.4 (required): Array indexing shall be the only allowed form of pointer arithmetic.
Therefore, the solution to this issue is to use the "-allow-ptr-arith-on-struct" option and treat the orange as safe.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by