[Bug c/103996] Enhancement: Better diagnostic for invalid reuse of a function name

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 12 18:23:48 GMT 2022


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-12
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Simplified testcase:
void f(void);
int main(void)
{
    f[0] = 0;
}
The C++ front-end for the above testcase produces:
<source>: In function 'int main()':
<source>:4:8: warning: pointer to a function used in arithmetic
[-Wpointer-arith]
    4 |     f[0] = 0;
      |        ^
<source>:4:10: error: assignment of read-only location '* f'
    4 |     f[0] = 0;
      |     ~~~~~^~~

For a slightly different one:
void f(void);
void f(int);
int main(void)
{
    f[0] = 0;
}
The C++ fornt-end produces similar to what was done in the index case.


More information about the Gcc-bugs mailing list