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

--- Comment #7 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
For reference, current output of the test case from comment #0 with trunk is
  https://godbolt.org/z/8hYY3eaoa

<source>: In function 'f':
<source>:5:8: error: assignment to 'int *' from incompatible pointer type 'char
*' [-Wincompatible-pointer-types]
    5 |   s->p = s->q;
      |        ^
<source>:6:8: warning: assignment discards 'const' qualifier from pointer
target type [-Wdiscarded-qualifiers]
    6 |   s->q = s->r;
      |        ^


Ideally we'd probably add secondary locations with labels:

<source>: In function 'f':
<source>:5:8: error: assignment to 'int *' from incompatible pointer type 'char
*' [-Wincompatible-pointer-types]
    5 |   s->p = s->q;
      |   ~~~~ ^ ~~~~
      |    |      |
      |    int *  char *
<source>:6:8: warning: assignment discards 'const' qualifier from pointer
target type [-Wdiscarded-qualifiers]
    6 |   s->q = s->r;
      |   ~~~~ ^  ~~~
      |    |       |
      |    char *  const char *

though I don't know if the location data is available.

(In reply to Eric Gallager from comment #5)
[...]
> -Wdiscarded-qualifiers still doesn't say quite enough, IMO

Secondary locations with labels as above would help, but arguably the message
text should also say the types involved, perhaps worded as:

<source>:6:8: warning: assignment to 'char *' discards 'const' qualifier from
pointer target type 'const char *' [-Wdiscarded-qualifiers]

Reply via email to