Posts: 5
Threads: 2
Joined: Jan 2020
Reputation:
0
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?
Posts: 252
Threads: 1
Joined: Jun 2008
Reputation:
6
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.
Posted by and on behalf of
the MISRA C++ Working Group