https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91890
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #1)
> Confirmed. The diagnostic pragmas don't work very well for the middle-end
> warnings (e.g., with inlining, as discussed in bug 55881). In this test
> case, moving the #pragma GCC diagnostic ignored above the strcpy calls does
> the trick. I haven't looked into why. Something similar was reported in
> bug 66099. Manu had some ideas for how to make it work more reliably but I
> haven't had the time to work on it and don't expect to for GCC 10.
I don't think this is the same issue. In this case, the diagnostic is emitted
within the range affected by the #pragma.
In those other cases, the location at which the warning is emitted is not
within the range silenced by the #pragma (due to middle-end transformations or
inlining) so there is no way the #pragma can silence it.