[Bug c++/78667] nonsensical attribute alloc_size silently accepted

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri May 24 15:47:00 GMT 2019


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |9.0
         Resolution|---                         |FIXED
   Target Milestone|---                         |9.0
      Known to fail|                            |7.3.0, 8.2.0

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
The test case in comment #0 is diagnosed by GCC 9:

pr78667.c:2:1: warning: ‘alloc_size’ attribute ignored on a function returning
‘void’ [-Wattributes]
    2 | void f (int) __attribute__ ((alloc_size (1)));
      | ^~~~
pr78667.c:3:1: warning: ‘alloc_size’ attribute ignored on a function returning
‘long int’ [-Wattributes]
    3 | long g (int*) __attribute__ ((alloc_size (1)));
      | ^~~~

GCC 9 also rejects the test case in comment #2 with an error:

a.c:1:1: error: requested alignment is not an integer constant
    1 | void f (void) __attribute__ ((aligned ("foo")));
      | ^~~~
a.c:2:1: warning: ‘alloc_size’ attribute ignored on a function returning ‘void’
[-Wattributes]
    2 | void g (void) __attribute__ ((alloc_size ("bar")));
      | ^~~~


So this bug can be resolved as fixed.


More information about the Gcc-bugs mailing list