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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
The message could be improved by adding a note similar to the one GCC prints
for the same incompatibility in function argument initialization.  In the test
case below, the note in the second error makes it clear exactly where the
incompatibility is but it hard not to misread the first error as suggesting the
problem is also in the argument initialization.  In both cases, the placement
of the caret on the opening parenthesis (rather than on the first letter of the
function name) doesn't seem like the most fortunate choice, especially with the
char** being right under it.

$ gcc -S -Wall z.C
char **f (const char**);

void g (const char **s)
{
  const char **a = f (s);
  g (f (s));
  (void)&a;
}
z.C: In function ‘void g(const char**)’:
z.C:5:22: error: invalid conversion from ‘char**’ to ‘const char**’
[-fpermissive]
    5 |   const char **a = f (s);
      |                    ~~^~~
      |                      |
      |                      char**
z.C:6:8: error: invalid conversion from ‘char**’ to ‘const char**’
[-fpermissive]
    6 |   g (f (s));
      |      ~~^~~
      |        |
      |        char**
z.C:3:22: note:   initializing argument 1 of ‘void g(const char**)’
    3 | void g (const char **s)
      |         ~~~~~~~~~~~~~^

Reply via email to