https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79062
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- The following allows the format string to be recognized even with LTO. The sprintf pass runs and seems to work correctly, but warnings from it for some reason do not appear on output. It's as if they were disabled. I'm not sure what's causing that. diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index 85f97b2..687a87f 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -373,7 +373,16 @@ get_format_string (tree format, location_t *ploc) if (TREE_CODE (format) != STRING_CST) return NULL; - if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (format))) != char_type_node) + tree type = TREE_TYPE (format); + if (TREE_CODE (type) == ARRAY_TYPE) + type = TREE_TYPE (type); + + /* Can't just test that: + TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (format))) != char_type_node + See bug 79062. */ + if (TREE_CODE (type) != INTEGER_TYPE + || TYPE_MODE (type) != TYPE_MODE (char_type_node) + || TYPE_PRECISION (type) != TYPE_PRECISION (char_type_node)) { /* Wide format string. */ return NULL;