Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
Use of the '{0}' initializer on structure objects which have aggregate members
produces a warning when compiled with -Wextra.
Example:
file a.c :
<quote>
struct s { int a ; char *b; struct { float c; char d ; } e; char f ; };
typedef struct s t;
void f(void)
{
t v={0};
}
</quote>
$ gcc -std=c99 -Wall -Wextra -c a.c
a.c: In function 'f':
a.c:5: warning: missing initializer
a.c:5: warning: (near initialization for 'v.b')
a.c:5: warning: unused variable 'v'
According to C99 (n1124.pdf), section 6.7.8 paragraph 21:
<quote>
If there are fewer initializers in a brace-enclosed list than there are
elements or members of an aggregate, or fewer characters in a string literal
used to initialize an array of known size than there are elements in the array,
the remainder of the aggregate shall be initialized implicitly the same as
objects that have static storage duration.
</quote>
Indeed, gcc-4.8.x emits only the "unused variable 'v'" warning with the same
command line, so this appears to be fixed upstream.
Warning such as this get me worried - does the object truly contain an
uninitialized 'b' member, or is the warning bogus ?
Version-Release number of selected component (if applicable):
4.4.7-3
$ gcc -v | tail -n 1:
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
How reproducible:
100%
Steps to Reproduce:
try to compile code containing a partial structure initializer of an
object containing aggregate members
Actual results:
gcc emits 'missing initializer' warning with -Wextra.
Expected results:
gcc should be fully initializing the structure object's memory to all 0's and
not emitting a warning in this case, even with -Wextra.
Additional info:
This was changed with http://gcc.gnu.org/PR36750, but I'd say it is highly undesirable to change the warnings in an existing gcc release. -Wextra certainly includes various warnings that go beyond what the standard mandates, the exception made for PR36750 was for C only and only for { 0 } initializers, e.g. if you write { 0, 0 }; even latest GCC will still complain about missing initializers. It is true they are initialized with zero, on the other side not always is that the intended thing, often just some initializers were forgotten (say, you have a structure, write initializer for it when it has 2 fields, then add another field and forget to add initializer for that).
See -Wmissing-field-initializers documentation.
Description of problem: Use of the '{0}' initializer on structure objects which have aggregate members produces a warning when compiled with -Wextra. Example: file a.c : <quote> struct s { int a ; char *b; struct { float c; char d ; } e; char f ; }; typedef struct s t; void f(void) { t v={0}; } </quote> $ gcc -std=c99 -Wall -Wextra -c a.c a.c: In function 'f': a.c:5: warning: missing initializer a.c:5: warning: (near initialization for 'v.b') a.c:5: warning: unused variable 'v' According to C99 (n1124.pdf), section 6.7.8 paragraph 21: <quote> If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration. </quote> Indeed, gcc-4.8.x emits only the "unused variable 'v'" warning with the same command line, so this appears to be fixed upstream. Warning such as this get me worried - does the object truly contain an uninitialized 'b' member, or is the warning bogus ? Version-Release number of selected component (if applicable): 4.4.7-3 $ gcc -v | tail -n 1: gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) How reproducible: 100% Steps to Reproduce: try to compile code containing a partial structure initializer of an object containing aggregate members Actual results: gcc emits 'missing initializer' warning with -Wextra. Expected results: gcc should be fully initializing the structure object's memory to all 0's and not emitting a warning in this case, even with -Wextra. Additional info: