4 ms·
Sometime it is a compiler bug and sometimes the linker even can correct it. We had this weird behavior some years ago in an embedded functional safety-related
by PinguTS 9y ago
Sometime it is a compiler bug and sometimes the linker even can correct it.
We had this weird behavior some years ago in an embedded functional safety-related project where a case tool generated the code for the compiler.
When the generated code looked like this:
i++;
i++;
i++;
i++;
i++;
if (i > something) {
} else {
}
Then the compiler was miscalculating the jump by 2 bytes in the else path.
But if the generated code was this (spot the difference):
i++;
i++;
i++;
i++;
if (i > something) {
} else {
}
The compiler correctly calculated the jumps. If certain optimization option was enabled, the linker afterwards corrected the miscalculated jump.
The compiler vendor could reproduce the behavior aka bug, but could not say with confidence the circumstaalnce what the cause for this bug was. As it was for a function safety-related product we where required to identify all jumps caused by if clauses and had to review the assembly, if the jumps in the assembly were correct.