https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231
Bug ID: 108231 Summary: g++ mistakenly reports ambiguity between equivalent function declarations Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bruno at clisp dot org Target Milestone: --- Created attachment 54156 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54156&action=edit test case The attached code, i1.cc, contains two equivalent function declarations for the function 'free'. They are equivalent because they have the same signature and both have "C" linkage. In lines 9, 10, 12, 13, referencing the function 'free' works fine. However, referencing it in line 17, as part of a __attribute__ ((__malloc__ (free, 1))) attribute, leads to an error "‘malloc’ attribute argument 1 is ambiguous". I would expect no error, no warning. How to reproduce: $ g++ -S i1.cc i1.cc:17:67: error: ‘malloc’ attribute argument 1 is ambiguous 17 | __attribute__ ((__malloc__)) __attribute__ ((__malloc__ (free, 1))); | ^ i1.cc:17:67: note: use a cast to the expected type to disambiguate