[Bug lto/83954] [6/7/8 Regression] LTO: Bogus -Wlto-type-mismatch warning for array of pointer to incomplete type
hubicka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 25 14:15:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83954
--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
It is not going to produce wrong code. GCC knows that pointers to incomplete
types alias with pointers to complete types and it also handles array by alias
sets of their elements. What is wrong here is that the warning conditional
rules out the false positive for pointers but not for arrays of pointers.
This should silence the warning.
Index: lto-symtab.c
===================================================================
--- lto-symtab.c (revision 257048)
+++ lto-symtab.c (working copy)
@@ -285,7 +285,9 @@ warn_type_compatibility_p (tree prevaili
alias_set_type set2 = get_alias_set (prevailing_type);
if (set1 && set2 && set1 != set2
- && (!POINTER_TYPE_P (type) || !POINTER_TYPE_P (prevailing_type)
+ && (((!POINTER_TYPE_P (type) || !POINTER_TYPE_P (prevailing_type))
+ && (TREE_CODE (type) != ARRAY_TYPE
+ || TREE_CODE (prevailing_type) != ARRAY_TYPE))
|| (set1 != TYPE_ALIAS_SET (ptr_type_node)
&& set2 != TYPE_ALIAS_SET (ptr_type_node))))
lev |= 5;
More information about the Gcc-bugs
mailing list