https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119476
Bug ID: 119476 Summary: [-Wdiscarded-qualifiers] False negative with -fplan9-extensions inheritance Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alx at kernel dot org Target Milestone: --- alx@devuan:~/tmp$ cat q.c | grep -Tn ^ 1: struct foo { 2: int a; 3: }; 4: 5: struct bar { 6: struct foo; 7: }; 8: 9: void f(struct foo *); 10: void g(char *); 11: 12: int 13: main(void) 14: { 15: const struct bar b; 16: 17: f(&b); 18: 19: const char *s = "foo"; 20: 21: g(s); 22: } alx@devuan:~/tmp$ gcc -Wall -Wextra -fplan9-extensions -S q.c q.c: In function ‘main’: q.c:21:11: warning: passing argument 1 of ‘g’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 21 | g(s); | ^ q.c:10:8: note: expected ‘char *’ but argument is of type ‘const char *’ 10 | void g(char *); | ^~~~~~ Line 17 should trigger a similar diagnostic. It seems inheritance is not inheriting the qualifiers from the declared type of the object, which was 'const struct bar', and whose const is propagated to all members.