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

            Bug ID: 103738
           Summary: No warning when setting deprecated fields using
                    designated initializers
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at haasn dot dev
  Target Milestone: ---

Created attachment 52009
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52009&action=edit
No deprecation warning produced

Deprecated attributes on struct members are ignored when setting those fields
using designated initializers. The attached example should produce a warning,
but it does not.

Contrast the following alternative code:

    struct foo foo;
    foo.bar = 5;

This does produce a deprecation warning as expected:

no_warning.c: In function ‘main’:
no_warning.c:8:5: warning: ‘bar’ is deprecated [-Wdeprecated-declarations]
    8 |     foo.bar = 5;
      |     ^~~
no_warning.c:2:9: note: declared here
    2 |     int bar __attribute((deprecated));
      |         ^~~

Reply via email to