https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91890
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- I'm 100% convinced this has nothing to do with locations and all to do with how -Warray-bounds and -Wstringop-overflow= interact. Change the ignored for error, char one[50]; char two[50]; void test_strncat (void) { (void) __builtin_strcpy (one, "gh"); (void) __builtin_strcpy (two, "ef"); #pragma GCC diagnostic ignored "-Wstringop-overflow" #pragma GCC diagnostic error "-Warray-bounds" (void) __builtin_strncat (one, two, 99); } and run with -Wall -O2 -Wno-array-bounds and we get: <source>:10:28: error: 'char* __builtin_strncat(char*, const char*, long unsigned int)' forming offset [50, 98] is out of the bounds [0, 50] of object 'one' with type 'char [50]' [-Werror=array-bounds] so the #pragma has an effect, but there is something weird with ignored and -Wstringop-overflow interaction.