Disable Warray-bounds check on GCC 12 builds
Fixes #2506 (closed)
There is a bug on GCC 12 that triggers false positive warnings of the type -Warray-bounds. This makes Eigen really hard to use on modern GCC versions, since you either have to disable this check globally or wrap your eigen #include directives with #pragma GCC diagnostic ignored "-Warray-bounds", which is difficult to maintain.
I used compiler explorer to verify that the bug is still present on GCC 14.2 AKA the latest version available at the time of writing.
I understand that this is not an Eigen bug and it should be up to GCC to address this, but the GCC bug report has been open for over 2 years with no sign of development. And even if they come up with a fix tomorrow there will still be a wide range of GCC versions (12.0 - 14.2) which do not play nicely with Eigen.
This PR builds on top of some machinery that Eigen already has in place and it is even used for a similar reason a few lines above -- that is, to disable a check that triggers false positive warnings.
Eric.