AutosarC++17_03-A7.4.1ΒΆ

The asm declaration shall not be used

Rationale

Inline assembly code restricts the portability of the code.

Example
// $Id: A7-4-1.cpp 271687 2017-03-23 08:57:35Z piotr.tanski $
#include <cstdint>
std::int32_t fn1(std::int32_t b) noexcept {
std::int32_t ret = 0;
// ...
asm("pushq %%rax \n"
"movl %0, %%eax \n"
"addl %1, %%eax \n"
"movl %%eax, %0 \n"
"popq %%rax"
: "=r"(ret)
: "r"(b)); // Non-compliant
return ret;
}
std::int32_t fn2(std::int32_t b) noexcept {
std::int32_t ret = 0;
// ...
ret += b; // Compliant - equivalent to asm(...) above
return ret;
}
See Also
  • HIC++ v4.0 [8]: 7.5.1 Do not use the asm declaration.

Possible Messages

Key

Text

Severity

Disabled

use_of_assembler

Use of assembler.

None

False

Options