Error : 'H_MAG[16]' may be used uninitialized

how can u fix it?

1 Like

What firmware version are you compiling?
Did you do any changes to the source code?

1 Like

arducopter 4.0.4
I can compile on another pc.

Do not do that. Please consider using at least ArduCopter 4.0.7.

And yes, please try another PC.

1 Like

What’s the cause?
Firmware Below 4.0.7 can’t compile at all.

The cause is that firmware bellow 4.0.7 has bugs (some critical) that have been fixed in ArduCopter 4.0.7.
We do minor software releases to fix important bugs, not for the sake of releasing new features or introducing regressions.

The ArduCopter release notes are public as the rest of the source code. There you can see exactly what changed.

And ArduCopter 4.1.3 has already been released. It has been under test for since around May 2021.

And you can just grab the precompiled firmware from our firmware server

1 Like

I put … #pragma GCC diagnostic ignored “-Wuninitialized”
to ignore them.

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored “-Wuninitialized”
// correct the covariance P = (I - K*H)*P
// take advantage of the empty columns in KH to reduce the
// number of operations
for (unsigned i = 0; i<=stateIndexLim; i++) {
for (unsigned j = 0; j<=2; j++) {
KH[i][j] = Kfusion[i] * H_MAG[j];
}
for (unsigned j = 3; j<=15; j++) {
KH[i][j] = 0.0f;
}
for (unsigned j = 16; j<=21; j++) {
KH[i][j] = Kfusion[i] * H_MAG[j];
}
for (unsigned j = 22; j<=23; j++) {
KH[i][j] = 0.0f;
}
}
#pragma GCC diagnostic pop