AutosarC++18_03-A7.4.1ΒΆ
The asm declaration shall not be used
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
Inline assembly code restricts the portability of the code.
Example
// $Id: A7-4-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#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
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.