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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonny Grant from comment #0)
> Could g++ indicate the carat on returned var?

It is doing.

The declaration of a variable 'const char** a' is not "the returned var".

The value returned by f() is best indicated by marking the expression f()
itself.

> C++ Godbolt trunk actual:
>    10 |     const char **a = f();
>       |                      ~^~
> 
> C++ Expected:
>    10 |     const char **a = f();
>       |     ~^~


For a start, highlighting just "con" is not very helpful.

Even if you highlighted the whole declarator (or just the type name) I don't
think this is a good idea. Semantically, the problem is that using f() as the
initializer for a 'const char**' is not the right type (and can't be converted
to the right type). The problem is not the type of 'a' it's the initializer.
Declaring a const char** is not a bug, but trying to initialize it from an
incompatible type is a bug.

You suggestion doesn't work in other cases. What would you highlight here?

  const char** g(const char**);
  const char** a = g(f());

Obviously you don't want to highlight the declaration of 'a' here because it's
fine. The problem is trying to initialize the parameter of 'g' with an
expression of  the wrong type, namely f().

So we highlight f().

Reply via email to