This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wmissing-field-initializers says Âmissing initializer for member when it obviously isn't.


Hi,

On 09/10/2014 04:39 PM, Hi-Angel wrote:
Below is a sample code to test. GCC with the option allegedly says
that the line Âobj = {0}; isn't initializes Âmystruct::b member to
anything, although it really is.

struct mystruct{
         int a;
         int b[2];
};

int main(){
         mystruct obj = {1,{2,3}};
         printf("%i\n", obj.b[1]);
         obj = {0};
         printf("%i\n", obj.b[1]);
         return 0;
}

A bug?
I don't see anything wrong with the warning vs your snippet. You may want to read the audit trail of Bug c++/61489 for clarifications.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]