Bug 1029448

Summary: option -Wmissing-field-initializers does not work
Product: [Fedora] Fedora Reporter: Jorge Stolfi <stolfi>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: jakub, law, mpolacek, stolfi
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-13 06:47:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
source code that exhibits the bug none

Description Jorge Stolfi 2013-11-12 12:10:50 UTC
Created attachment 822887 [details]
source code that exhibits the bug

Description of problem:

  The gcc compiler option "-Wmissing-field-initializers" appears to have no
  effect, and is not flagged as invalid option.

Version-Release number of selected component (if applicable):

  gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)

How reproducible: 100%


Steps to Reproduce:

  Compile the attached C source with

    gcc -Wmissing-field-initializers missing-fields.c

  The program defines a struct type with three fields,
  declares a variable of that type, assigns it a constructor
  that is missing one of the fields.

Actual results:

    gcc -Wmissing-field-initializers missing-fields.c
    Compilation finished at Tue Nov 12 10:09:14

Expected results:

  According to the gcc 4.7.2 info
  file, the omission should have been flagged.

Additional info:

Comment 1 Marek Polacek 2015-02-12 14:21:38 UTC
That is intentional, even the gcc manual says
  This option does not warn about designated initializers, so the
  following modification does not trigger a warning:

         struct s { int f, g, h; };
         struct s x = { .f = 3, .g = 4 };

But there's an upstream RFE for what you want: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39589

Comment 2 Marek Polacek 2015-02-13 06:47:09 UTC
Tracking upstream then.