https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98992
Bug ID: 98992 Summary: attribute malloc error associating a member deallocator with an allocator Product: gcc Version: 11.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 new attribute malloc is rejected on declarations of member function: $ cat t.C && /build/gcc-master/gcc/xg++ -B /build/gcc-master/gcc -S -Wall t.C struct A { void dealloc (void*); __attribute__ ((malloc (dealloc))) void* alloc (); }; t.C:6:16: error: ‘malloc’ attribute argument 1 does not name a function 6 | void* alloc (); | ^ The attribute handler is prepared for FUNCTION_DECL and OVERLOAD but not for how a member function is represented here: <component_ref 0x7fffea969930 type <lang_type 0x7fffea9532a0 unknown type type <lang_type 0x7fffea9532a0 unknown type> VOID align:1 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffea9532a0 pointer_to_this <lang_type 0x7fffea9532a0 unknown type> reference_to_this <lang_type 0x7fffea9532a0 unknown type>> arg:0 <indirect_ref 0x7fffea9549c0 type <record_type 0x7fffea96a000 S cxx-odr-p type_1 type_5 VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffea96a000 fields <function_decl 0x7fffea96d000 m_dealloc> context <translation_unit_decl 0x7fffea805168 /build/tmp/t.C> full-name "struct S" n_parents=0 use_template=0 interface-unknown pointer_to_this <pointer_type 0x7fffea96a150> chain <type_decl 0x7fffea8248e8 S>> arg:0 <convert_expr 0x7fffea9549a0 type <pointer_type 0x7fffea96a150> constant arg:0 <void_cst 0x7fffea809b50 type <void_type 0x7fffea815f18 void> constant>>> arg:1 <baselink 0x7fffea969900 type <method_type 0x7fffea96a690 type <void_type 0x7fffea815f18 void> QI size <integer_cst 0x7fffea7f7fa8 constant 8> unit-size <integer_cst 0x7fffea7f7fc0 constant 1> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffea96a690 method basetype <record_type 0x7fffea96a000 S> arg-types <tree_list 0x7fffea955f28 value <pointer_type 0x7fffea96a150> chain <tree_list 0x7fffea955f00 value <pointer_type 0x7fffea81fc78> chain <tree_list 0x7fffea80b8e8 value <void_type 0x7fffea815f18 void>>>>> functions <function_decl 0x7fffea96d000 m_dealloc type <method_type 0x7fffea96a690> used public private external decl_3 QI /build/tmp/t.C:8:8 align:16 warn_if_not_align:0 context <record_type 0x7fffea96a000 S> full-name "void S::m_dealloc(char*)" chain <function_decl 0x7fffea95af00 __dt >> binfo <tree_binfo 0x7fffea95e420 type <record_type 0x7fffea96a000 S> public private bases:0 offset <integer_cst 0x7fffea7f7ee8 0>> access_binfo <tree_binfo 0x7fffea95e420>> /build/tmp/t.C:9:27 start: /build/tmp/t.C:9:27 finish: /build/tmp/t.C:9:35>