Borrar filtros
Borrar filtros

False negatives for MISRA 9.3 missed for float array partial initialization

7 visualizaciones (últimos 30 días)
Hello,
Initializing an array of float in the following way:
float array_a[10] = { 0.0 };
should raise the MISRA violation 9.3, that forbids partial array initialization. However the polyspace code prover is not detecting this
violation. Please confirm if this is a false negative or some other issue. Thanks in advance.
Related to the question here:

Respuesta aceptada

Christian Bard
Christian Bard el 10 de Ag. de 2022
That is a specific Polyspace implementation of the rule 9.3. We have extended the exception 1 of the rule 9.3 with 0.0 and 0.0f.
  3 comentarios
Christian Bard
Christian Bard el 11 de Ag. de 2022
Amplification of the rule is about to initialize all elements of the array as soon as explicitely one is initialized. Exception applies on 0 and it looks like that float array_f[10] = { 0 }; is compliant but not float array_f[10] = { 0.0f }; Same for double array_d[10] = { 0 }; but not for double array_d[10] = {0.0};
From my stand point, not including 0.0 and 0.0f is really a very strict application of the rule because almost all compilers will mostly generate same assembly code for 0, 0.0 and 0.0f. Including 0.0 and 0.0f do not go against its rationale.
David Sosa
David Sosa el 11 de Ag. de 2022
Editada: David Sosa el 11 de Ag. de 2022
Ok. I understand the your rationale. Thanks for the detailed reply.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by