[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-10-01 Thread dcsommer at fb dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

Daniel Sommermann dcsommer at fb dot com changed:

   What|Removed |Added

 CC||dcsommer at fb dot com

--- Comment #10 from Daniel Sommermann dcsommer at fb dot com ---
Which release will this go out in?


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-10-01 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

Manuel López-Ibáñez manu at gcc dot gnu.org changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #11 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Daniel Sommermann from comment #10)
 Which release will this go out in?

GCC 5.1.0 presumably.

[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-09-11 Thread paolo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

--- Comment #8 from paolo at gcc dot gnu.org paolo at gcc dot gnu.org ---
Author: paolo
Date: Thu Sep 11 18:08:24 2014
New Revision: 215186

URL: https://gcc.gnu.org/viewcvs?rev=215186root=gccview=rev
Log:
2014-09-11  Paolo Carlini  paolo.carl...@oracle.com

PR c++/61489
* doc/invoke.texi ([-Wmissing-field-initializers]): Update.

/cp
2014-09-11  Paolo Carlini  paolo.carl...@oracle.com

PR c++/61489
* typeck2.c (process_init_constructor_record): Do not warn about
missing field initializer if EMPTY_CONSTRUCTOR_P (init).

/testsuite
2014-09-11  Paolo Carlini  paolo.carl...@oracle.com

PR c++/61489
* g++.dg/warn/Wmissing-field-initializers-1.C: New.
* g++.old-deja/g++.other/warn5.C: Adjust.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wmissing-field-initializers-1.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck2.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.old-deja/g++.other/warn5.C


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-09-11 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Assignee|paolo.carlini at oracle dot com|unassigned at gcc dot 
gnu.org
   Target Milestone|--- |5.0

--- Comment #9 from Paolo Carlini paolo.carlini at oracle dot com ---
Done.


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-09-10 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |paolo.carlini at oracle 
dot com

--- Comment #7 from Paolo Carlini paolo.carlini at oracle dot com ---
Mine.


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-06-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-06-14
 Ever confirmed|0   |1
   Severity|normal  |enhancement

--- Comment #6 from Jonathan Wakely redi at gcc dot gnu.org ---
(In reply to Deniz Bahadir from comment #5)
 Because of several internet-sources, like the one I cited, I always thought
 that the cases of addr3 and addr7 were the prefered way of explicitely
 forcing zero-initialization of all struct members (especially if the number
 of struct-members are subject to change in the future).

That's the preferred way in C, where at least one initializer is needed, but
not in C++.

 If I understand you correctly, a better/cleaner way which achieves the exact
 same is using the cases of addr2 and addr6.

Yes.

 Then I would rephrase my original statement and suggest that no warning will
 be issued for cases of addr2, addr6 and addr9.

I agree with that suggestion.


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-06-13 Thread D.Bahadir at GMX dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

--- Comment #3 from Deniz Bahadir D.Bahadir at GMX dot de ---
Thanks for the comment.

So, at least we aggree that the cases for addr2 and addr6 should not warn (in
C++11) as it initializes all values. Possibly this holds true for addr9, too?

I always thought that the cases for addr3 and addr7 (and maybe also addr4 and
addr8) should initialize the entire struct with zeros. (This is for example
mentioned in that explanation:
http://www.codeguru.com/cpp/cpp/article.php/c19081/C-2011-Uniform-Initialization.htm)
By a quick look through the C++11 standard I was not able to find the section
which states that.
However, I found something similar in section 8.5.1 Aggregates, paragraph 7:

If there are fewer initializer-clauses in the list than there are members in
the aggregate, then each member not explicitly initialized shall be initialized
from an empty initializer list (8.5.4). [ Example:
struct S { int a; const char* b; int c; };
S ss = { 1, asdf };
initializes ss.a with 1, ss.b with asdf, and ss.c with the value of an
expression of the form int(), that is, 0. —end example ]

So, I am unsure if the compiler should warn about that or not.

Could maybe someone clarify if the statement from the link above about the
cases addr3 and addr7 is correct?

[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-06-13 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

--- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org ---
(In reply to Deniz Bahadir from comment #3)
 Thanks for the comment.
 
 So, at least we aggree that the cases for addr2 and addr6 should not warn
 (in C++11) as it initializes all values.

No, that's not why I said it should not warn. All your examples except addr0
initialize all values, that's not the point. Please read the fine manual, the
warning is explicitly documented to warn when some members are implicitly set
to zero.

The warning is NOT designed to tell you about uninitialized members. It is
designed to tell you about implicitly zero-initialized members. So please stop
claiming it shouldn't warn when all members are zero-initialized, that's
EXACTLY what the warning is for.

(I think {} should not warn in C++11 because it is similar to the addr5 case,
which is explicit value-initialization. Although technically your cases are
still aggregate-initialization not value-initialization even with {})


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-06-13 Thread D.Bahadir at GMX dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

--- Comment #5 from Deniz Bahadir D.Bahadir at GMX dot de ---
Thanks again.
Then I need to appologize for misunderstanding the meaning of the warning-flag.

Because of several internet-sources, like the one I cited, I always thought
that the cases of addr3 and addr7 were the prefered way of explicitely forcing
zero-initialization of all struct members (especially if the number of
struct-members are subject to change in the future).

If I understand you correctly, a better/cleaner way which achieves the exact
same is using the cases of addr2 and addr6.

Then I would rephrase my original statement and suggest that no warning will be
issued for cases of addr2, addr6 and addr9.


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-06-12 Thread D.Bahadir at GMX dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

--- Comment #1 from Deniz Bahadir D.Bahadir at GMX dot de ---
This does not only occur with GCC 4.9.0 but also with older ones like 4.7 and
4.8.


[Bug c++/61489] Wrong warning with -Wmissing-field-initializers.

2014-06-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

--- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org ---
(In reply to Deniz Bahadir from comment #0)
 When compiling the following code (in C++11 mode) with
 -Wmissing-field-initializers then almost all attempts to initialize
 sockaddr_in result in compiler-warnings about uninitialized field-members.
 However, as far as I understand, almost all initializations should be fine
 and zero-initialize (?) all struct-members and the compiler-warnings should
 therefore not occur.

But that's exactly the situation -Wmissing-field-initializers is designed to
warn about, so the warning is not wrong.


 
 
 code
 // Compile this code with: g++ -std=c++11 -Wmissing-field-initializers
 bug.cpp
 
 #include netinet/in.h
 
 int main()
 {
 struct sockaddr_in addr0;  // No warning. But really
 zero-initialized?

No, uninitialized.

 //struct sockaddr_in addr1();  // No warning, but a function-declaration.


 struct sockaddr_in addr2 = {};// In C++: Warning about all members.

I think it shouldn't warn for an empty braced-init-list, as that has special
meaning in C++11.

   // In C: Warning about first member.

It's not valid in C, you always need at least one initializer.


 struct sockaddr_in addr3 = {0};   // In C++: Warning about all members
   // except the first one.
 struct sockaddr_in addr4 = {0,};  // Same here.

That's exactly what the warning is designed to warn about.

 #ifdef __cplusplus
 struct sockaddr_in addr5 = sockaddr_in();  // No warning and (probably)
// zero-initialized.

Definitely zero-initialized.