https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89985
Bug ID: 89985 Summary: [9 Regression] Stray notes from OPT_Waddress_of_packed_member with -w Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- Given the following source: typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; struct a { uint8_t f0; uint8_t f1; uint16_t f2; } __attribute__((packed)); struct b { uint16_t f0; }; void test (struct a *p) { struct b *q= (struct b *)p; } when compiled with -w, gcc 9 emits just these stray notes: rhbz1696441.c: In function ‘test’: ../../src/rhbz1696441.c:5:8: note: defined here 5 | struct a { | ^ rhbz1696441.c:11:8: note: defined here 11 | struct b { | ^ (from downstream report https://bugzilla.redhat.com/show_bug.cgi?id=1696441 ) The notes are followups to -Waddress-of-packed-member warnings, which aren't being properly guarded by emission of that warning in c-family/c-warn.c: 2776 warning_at (location, OPT_Waddress_of_packed_member, 2777 "converting a packed %qT pointer (alignment %d) " 2778 "to a %qT pointer (alignment %d) may result in an " 2779 "unaligned pointer value", 2780 rhstype, rhs_align, type, type_align); 2781 tree decl = TYPE_STUB_DECL (rhstype); 2782 if (decl) 2783 inform (DECL_SOURCE_LOCATION (decl), "defined here"); 2784 decl = TYPE_STUB_DECL (type); 2785 if (decl) 2786 inform (DECL_SOURCE_LOCATION (decl), "defined here"); which is normally guarded by: 2886 warn_for_address_or_pointer_of_packed_member (tree type, tree rhs) 2887 { 2888 if (!warn_address_of_packed_member) 2889 return; but the "-w" sidesteps this (via diagnostic_report_warnings_p). Appears to be new with gcc 9. I'm working on a fix.