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

            Bug ID: 89813
           Summary: bogus warning: ’assume_aligned’ <large integer> is not
                    an integer constant
           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: ---

The warning below that 9223372036854775808 is not an integer constant is 
incorrect: the number is an integer constant, it just exceeds the supported
maximum.  It's caused by using tree_fits_shwi_p() to detect both excessive
values and non-integers.

The error below is an example of what a better warning should look like.

$ cat b.c && gcc -S b.c
#define N ((__UINT64_TYPE__)1 << 63)

__attribute__ ((assume_aligned (N))) void* f (void);

struct S
{
  __attribute__ ((warn_if_not_aligned (N))) int i;
};
b.c:3:1: warning: ‘assume_aligned’ attribute 9223372036854775808 is not an
integer constant [-Wattributes]
    3 | __attribute__ ((assume_aligned (N))) void* f (void);
      | ^~~~~~~~~~~~~
b.c:7:3: error: requested alignment ‘9223372036854775808’ exceeds maximum
2147483648
    7 |   __attribute__ ((warn_if_not_aligned (N))) int i;
      |   ^~~~~~~~~~~~~

Reply via email to