This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/81566] New: attribute aligned with no argument accepted on functions


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

            Bug ID: 81566
           Summary: attribute aligned with no argument accepted on
                    functions
           Product: gcc
           Version: 8.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 function form of attribute aligned is documented to take an argument but
not without:

  aligned (alignment)
      This attribute specifies a minimum alignment for the function, measured
in bytes.

In addition, the manual states that

  You cannot use this attribute to decrease the alignment of a function, only
to increase it. 

However, GCC accepts the attribute even without an argument, and it also
accepts declarations that appear to decrease the alignment of a function only
to proceed to silently ignore them.  See the test case below.

The manual should be updated and the effect of the attribute without an
argument (or GCC changed to reject it), and the attribute handler should be
enhanced to issue -Wattributes for attribute arguments that violate the
requirements outlined in the manual.

$ cat x.c && /ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -O2 -S -Wall
-Wextra -Wpedantic -o/dev/stdout x.c
int __attribute__ ((aligned)) f (void);

int __attribute__ ((aligned (4))) f (void);
int __attribute__ ((aligned (2))) f (void);
int __attribute__ ((aligned (1))) f (void);
int __attribute__ ((aligned (0))) f (void);

int f (void) { return 0; }

int __attribute__ ((aligned (2))) g (void);
int __attribute__ ((aligned (1))) g (void);
int __attribute__ ((aligned (0))) g (void);

int g (void) { return 0; }

        .file   "x.c"
        .text
        .align 16
        .globl  f
        .type   f, @function
f:
.LFB0:
        .cfi_startproc
        xorl    %eax, %eax
        ret
        .cfi_endproc
.LFE0:
        .size   f, .-f
        .align 2
        .globl  g
        .type   g, @function
g:
.LFB1:
        .cfi_startproc
        xorl    %eax, %eax
        ret
        .cfi_endproc
.LFE1:
        .size   g, .-g
        .ident  "GCC: (GNU) 8.0.0 20170717 (experimental)"
        .section        .note.GNU-stack,"",@progbits

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]