[Bug c/89798] New: excessive vector_size silently accepted and truncated

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 22 17:26:00 GMT 2019


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

            Bug ID: 89798
           Summary: excessive vector_size silently accepted and truncated
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

In the following test case the declaration of v0 is accepted and its size
matches the size specified by the vector_size attribute.  The declaration of v1
is also accepted but its size does not match that specified by the same
attribute.  See also pr89797 for a similar test case that triggers an ICE.

GCC should validate the attribute argument against its internal maximum and
reject excessive arguments with a descriptive error.

$ cat z.c && gcc -S -Wall -Wextra z.c
#define N0   (1LU << 30)

__attribute__ ((vector_size (N0))) char v0;
_Static_assert (N0 == sizeof v0);   // passes


#define N1   (1LU << 34)

__attribute__ ((vector_size (N1))) char v1;
_Static_assert (N1 == sizeof v1);   // fails
z.c:10:1: error: static assertion failed
   10 | _Static_assert (N1 == sizeof v1);   // fails
      | ^~~~~~~~~~~~~~


More information about the Gcc-bugs mailing list