http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58270
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target|i386-pc-linux | Status|WAITING |NEW CC| |rguenth at gcc dot gnu.org Component|fortran |middle-end Host|i386-pc-linux | Summary|Wrong code while accessing |Wrong code while accessing |array elements in a global |trailing array elements in |structure |a global common structure Known to fail| |4.9.0 --- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> --- DECL_COMMONs could be special-cased in places that look at DECL_SIZE (I'll declare this a QOI issue). Or all decls that do not bind locally. The place that would "fix" tree-fre, tree-pre and tree-dse is in get_ref_base_and_extent where it does if (DECL_P (exp)) { /* If maxsize is unknown adjust it according to the size of the base decl. */ if (maxsize == -1 && host_integerp (DECL_SIZE (exp), 1)) maxsize = TREE_INT_CST_LOW (DECL_SIZE (exp)) - hbit_offset; } else if (CONSTANT_CLASS_P (exp)) { /* If maxsize is unknown adjust it according to the size of the base type constant. */ if (maxsize == -1 && host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)) maxsize = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) - hbit_offset; } In its general processing the function treats all trailing arrays as possibly of undefined size. Note that because -fcommon is still the default for all C dialects the impact of changing the above for example in the simple && !DECL_COMMON (exp) way is unknown. -fcommon is a source of interesting bugs.