https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97860

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
As I said, [0] is not a VLA bound.
And we don't record anything for constant bounds (even if they are in the
middle).
So perhaps:
              /* array_type_nelts assumes the middle-end TYPE_DOMAINs, while
                 GNU [0] array in the FE don't have TYPE_MAX_VALUE of the
                 domain set, yet they are complete types with no elements.  */
              if (nelts == error_mark_node
                  && TYPE_DOMAIN (type)
                  && !TYPE_MAX_VALUE (TYPE_DOMAIN (type))
                  && COMPLETE_P (type)
                  && integer_zerop (TYPE_SIZE (type)))
                continue;
              if (error_mark_operand (nelts))
                return attrs;
which would bail for errors, but would handle [0] complete arrays as
non-errors.
After all, even for those it might be meaningful to complain about out of
bounds accesses.
Sure, for [0] arrays all dereferences are invalid, but taking address of
element [0] is ok.

Reply via email to