MISRA Discussion Forums
A8-5-2 + A8-5-3: No usage of auto allowed? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: AUTOSAR C++:2014 rules (https://forum.misra.org.uk/forumdisplay.php?fid=185)
+--- Thread: A8-5-2 + A8-5-3: No usage of auto allowed? (/showthread.php?tid=1654)



A8-5-2 + A8-5-3: No usage of auto allowed? - chgros - 11-08-2023

It appears that it's impossible to use `auto` variables and be compliant with both A8-5-2 (which mandates {} initialization for all variables) and A8-5-3 (which forbids {} initialization for auto variables)
Is that the intention? How is one supposed to use lambdas in that case?


RE: A8-5-2 + A8-5-3: No usage of auto allowed? - cgpzs - 23-10-2023

(11-08-2023, 05:36 PM)chgros Wrote: It appears that it's impossible to use `auto` variables and be compliant with both A8-5-2 (which mandates {} initialization for all variables) and A8-5-3 (which forbids {} initialization for auto variables)
Is that the intention? How is one supposed to use lambdas in that case?

Correct. You will need to follow a deviation process to allow that use case.


RE: A8-5-2 + A8-5-3: No usage of auto allowed? - misra cpp - 27-10-2023

You are correct that currently there is a contradiction between A8-5-2 and A8-5-3. This is highlighted in the examples for A8-5-3, which explicitly show non-compliances with A8-5-2. This can be used as part of the argument to deviate A8-5-2.

C++17 fixed the issue that A8-5-3 aims to prevent. If you are using a C++17 or later compiler, this can be used as part of the argument to deviate A8-5-3.

Autosar:2018 and MISRA C++:08 are about to be replaced by MISRA C++:23 which has been updated to remove these issues.