http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55383
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Status|UNCONFIRMED |NEW Last reconfirmed| |2012-11-18 CC| |manu at gcc dot gnu.org Ever Confirmed|0 |1 --- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-11-18 21:15:09 UTC --- Confirmed. The warning call is wrong: c/c-typeck.c-4468- /* There are qualifiers present in IN_OTYPE that are not present c/c-typeck.c-4469- in IN_TYPE. */ c/c-typeck.c-4470- warning_at (loc, OPT_Wcast_qual, c/c-typeck.c:4471: "cast discards %q#v qualifier from pointer target type", c/c-typeck.c-4472- discarded); c/c-typeck.c-4473- c/c-typeck.c-4474- if (added || discarded) It should use %qv for non-function types. Patch: Index: c/c-typeck.c =================================================================== --- c/c-typeck.c (revision 192847) +++ c/c-typeck.c (working copy) @@ -4466,11 +4466,11 @@ handle_warn_cast_qual (location_t loc, t if (discarded) /* There are qualifiers present in IN_OTYPE that are not present in IN_TYPE. */ warning_at (loc, OPT_Wcast_qual, - "cast discards %q#v qualifier from pointer target type", + "cast discards %qv qualifier from pointer target type", discarded); if (added || discarded) return; Index: testsuite/c-c++-common/Wcast-qual-1.c =================================================================== --- testsuite/c-c++-common/Wcast-qual-1.c (revision 192847) +++ testsuite/c-c++-common/Wcast-qual-1.c (working copy) @@ -83,15 +83,15 @@ f3 (void ***bar) } void f4 (void * const **bar) { - const void ***p9 = (const void ***) bar; /* { dg-warning "cast" } */ + const void ***p9 = (const void ***) bar; /* { dg-warning "cast discards .const. qualifier" } */ void * const **p11 = (void * const **) bar; - void ** const *p13 = (void ** const *) bar; /* { dg-warning "cast" } */ + void ** const *p13 = (void ** const *) bar; /* { dg-warning "cast discards .const. qualifier" } */ const void * const **p15 = (const void * const **) bar; /* { dg-warning "cast" } */ - const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast" } */ + const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast discards .const. qualifier" } */ void * const * const * p19 = (void * const * const *) bar; const void * const * const *p21 = (const void * const * const *) bar; }