public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/14482] New: hard to avoid -Weffc++ warnings with union members @ 2004-03-08 14:55 arnej at europe dot yahoo-inc dot com 2004-03-08 15:37 ` [Bug c++/14482] " pinskia at gcc dot gnu dot org 2004-04-28 19:06 ` pinskia at gcc dot gnu dot org 0 siblings, 2 replies; 9+ messages in thread From: arnej at europe dot yahoo-inc dot com @ 2004-03-08 14:55 UTC (permalink / raw) To: gcc-bugs We've found -Weffc++ very useful in general but union members produce a lot of noise about missing initializers. With a named union member it's possible to call the default constructor just to silence the warning, but with anonymous unions it's impossible. I've tried adding constructors to the union just to check how that would work but that just adds more warnings about those constructors not initializing the entire union (actually doing so is an error!) if possible, it would probably be better to just skip the "should be initialized in the member initialization list" warning for union members and for union constructors. test program: class Foo { public: enum { DBL, INTEGER } uniontype; // anonymous union { double dbl; int integer; }; // ordinary union { double named_dbl; int named_integer; } named; // with constructor union with_ctor_union { double named_dbl; int named_integer; with_ctor_union(int val) : named_integer(val) {} with_ctor_union(double val) : named_dbl(val) {} }; with_ctor_union with_ctor; Foo(int a) : uniontype(INTEGER), integer(a), named(), with_ctor(a) { named.named_integer = a; } Foo(double b) : uniontype(DBL), dbl(b), named(), with_ctor(b) { named.named_dbl = b; } }; warnings: uniont.cpp: In constructor `Foo::with_ctor_union::with_ctor_union(int)': uniont.cpp:22: warning: `Foo::with_ctor_union::named_dbl' should be initialized in the member initialization list uniont.cpp: In constructor `Foo::with_ctor_union::with_ctor_union(double)': uniont.cpp:23: warning: `Foo::with_ctor_union::named_integer' should be initialized in the member initialization list uniont.cpp: In constructor `Foo::Foo(int)': uniont.cpp:32: warning: `Foo::<anonymous>' should be initialized in the member initialization list uniont.cpp:32: warning: `Foo::<anonymous union>::dbl' should be initialized in the member initialization list uniont.cpp: In constructor `Foo::Foo(double)': uniont.cpp:41: warning: `Foo::<anonymous>' should be initialized in the member initialization list uniont.cpp:41: warning: `Foo::<anonymous union>::integer' should be initialized in the member initialization list Full gcc output: Reading specs from /snapshot/lib/gcc/i386-unknown-freebsd4.9/3.4.0/specs Configured with: ./configure --prefix=/snapshot Thread model: posix gcc version 3.4.0 20040303 (prerelease) /snapshot/libexec/gcc/i386-unknown-freebsd4.9/3.4.0/cc1plus -E -quiet -v uniont.cpp -Wall -Weffc++ -o uniont.ii ignoring nonexistent directory "/snapshot/lib/gcc/i386-unknown-freebsd4.9/3.4. 0/../../../../i386-unknown-freebsd4.9/include" #include "..." search starts here: #include <...> search starts here: /snapshot/lib/gcc/i386-unknown-freebsd4.9/3.4.0/../../../../include/c++/3.4.0 /snapshot/lib/gcc/i386-unknown-freebsd4.9/3.4.0/../../../../include/c++/3.4. 0/i386-unknown-freebsd4.9 /snapshot/lib/gcc/i386-unknown-freebsd4.9/3.4.0/../../../../include/c++/3.4. 0/backward /usr/local/include /snapshot/include /snapshot/lib/gcc/i386-unknown-freebsd4.9/3.4.0/include /usr/include End of search list. /snapshot/libexec/gcc/i386-unknown-freebsd4.9/3.4.0/cc1plus -fpreprocessed uniont.ii -quiet -dumpbase uniont.cpp -auxbase uniont -Wall -Weffc++ -version -o uniont.s GNU C++ version 3.4.0 20040303 (prerelease) (i386-unknown-freebsd4.9) compiled by GNU C version 2.95.4 20020320 [FreeBSD]. GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=130534 uniont.cpp: In constructor `Foo::with_ctor_union::with_ctor_union(int)': uniont.cpp:22: warning: `Foo::with_ctor_union::named_dbl' should be initialized in the member initialization list uniont.cpp: In constructor `Foo::with_ctor_union::with_ctor_union(double)': uniont.cpp:23: warning: `Foo::with_ctor_union::named_integer' should be initialized in the member initialization list uniont.cpp: In constructor `Foo::Foo(int)': uniont.cpp:32: warning: `Foo::<anonymous>' should be initialized in the member initialization list uniont.cpp:32: warning: `Foo::<anonymous union>::dbl' should be initialized in the member initialization list uniont.cpp: In constructor `Foo::Foo(double)': uniont.cpp:41: warning: `Foo::<anonymous>' should be initialized in the member initialization list uniont.cpp:41: warning: `Foo::<anonymous union>::integer' should be initialized in the member initialization list as -o uniont.o uniont.s -- Summary: hard to avoid -Weffc++ warnings with union members Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: arnej at europe dot yahoo-inc dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386-unknown-freebsd4.9 GCC host triplet: i386-unknown-freebsd4.9 GCC target triplet: i386-unknown-freebsd4.9 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members 2004-03-08 14:55 [Bug c++/14482] New: hard to avoid -Weffc++ warnings with union members arnej at europe dot yahoo-inc dot com @ 2004-03-08 15:37 ` pinskia at gcc dot gnu dot org 2004-04-28 19:06 ` pinskia at gcc dot gnu dot org 1 sibling, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-03-08 15:37 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-08 15:37 ------- Confirmed. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Keywords| |diagnostic Known to fail| |2.95.3 3.5.0 Last reconfirmed|0000-00-00 00:00:00 |2004-03-08 15:37:21 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members 2004-03-08 14:55 [Bug c++/14482] New: hard to avoid -Weffc++ warnings with union members arnej at europe dot yahoo-inc dot com 2004-03-08 15:37 ` [Bug c++/14482] " pinskia at gcc dot gnu dot org @ 2004-04-28 19:06 ` pinskia at gcc dot gnu dot org 1 sibling, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-04-28 19:06 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-28 17:00 ------- *** Bug 15192 has been marked as a duplicate of this bug. *** -- What |Removed |Added ---------------------------------------------------------------------------- CC| |uwe dot arzt at robots dot | |de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <bug-14482-8084@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members [not found] <bug-14482-8084@http.gcc.gnu.org/bugzilla/> @ 2009-04-28 23:42 ` pinskia at gcc dot gnu dot org 2009-12-10 10:56 ` brian dot amberg at unibas dot ch 2009-12-10 13:04 ` paolo dot carlini at oracle dot com 2 siblings, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2009-04-28 23:42 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from pinskia at gcc dot gnu dot org 2009-04-28 23:42 ------- *** Bug 39691 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hayden dot james at gmail | |dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members [not found] <bug-14482-8084@http.gcc.gnu.org/bugzilla/> 2009-04-28 23:42 ` pinskia at gcc dot gnu dot org @ 2009-12-10 10:56 ` brian dot amberg at unibas dot ch 2009-12-10 13:04 ` paolo dot carlini at oracle dot com 2 siblings, 0 replies; 9+ messages in thread From: brian dot amberg at unibas dot ch @ 2009-12-10 10:56 UTC (permalink / raw) To: gcc-bugs ------- Comment #4 from brian dot amberg at unibas dot ch 2009-12-10 10:56 ------- Confirming this bug for 4.2.4. This is annoying, especially when using effc++ with Werror. -- brian dot amberg at unibas dot ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |brian dot amberg at unibas | |dot ch http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members [not found] <bug-14482-8084@http.gcc.gnu.org/bugzilla/> 2009-04-28 23:42 ` pinskia at gcc dot gnu dot org 2009-12-10 10:56 ` brian dot amberg at unibas dot ch @ 2009-12-10 13:04 ` paolo dot carlini at oracle dot com 2 siblings, 0 replies; 9+ messages in thread From: paolo dot carlini at oracle dot com @ 2009-12-10 13:04 UTC (permalink / raw) To: gcc-bugs ------- Comment #5 from paolo dot carlini at oracle dot com 2009-12-10 13:04 ------- While you are at it, you can confirm it also with 4.3.x and 4.4.x: evidently nobody worked on this, otherwise the changes would show up in the audit trail. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <bug-14482-4@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members [not found] <bug-14482-4@http.gcc.gnu.org/bugzilla/> @ 2011-06-29 9:10 ` nocannedmeat at gmail dot com 2011-06-29 10:23 ` redi at gcc dot gnu.org 2011-06-29 10:56 ` redi at gcc dot gnu.org 2 siblings, 0 replies; 9+ messages in thread From: nocannedmeat at gmail dot com @ 2011-06-29 9:10 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 Aaron Miller <nocannedmeat at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nocannedmeat at gmail dot | |com --- Comment #6 from Aaron Miller <nocannedmeat at gmail dot com> 2011-06-29 09:09:48 UTC --- Confirmed for 4.5.2 "Ubuntu/Linaro 4.5.2-8ubuntu4" ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members [not found] <bug-14482-4@http.gcc.gnu.org/bugzilla/> 2011-06-29 9:10 ` nocannedmeat at gmail dot com @ 2011-06-29 10:23 ` redi at gcc dot gnu.org 2011-06-29 10:56 ` redi at gcc dot gnu.org 2 siblings, 0 replies; 9+ messages in thread From: redi at gcc dot gnu.org @ 2011-06-29 10:23 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail| | --- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-29 10:21:47 UTC --- but compiles without warnings using 4.6 or 4.7 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/14482] hard to avoid -Weffc++ warnings with union members [not found] <bug-14482-4@http.gcc.gnu.org/bugzilla/> 2011-06-29 9:10 ` nocannedmeat at gmail dot com 2011-06-29 10:23 ` redi at gcc dot gnu.org @ 2011-06-29 10:56 ` redi at gcc dot gnu.org 2 siblings, 0 replies; 9+ messages in thread From: redi at gcc dot gnu.org @ 2011-06-29 10:56 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14482 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Known to work| |4.6.0, 4.7.0 Resolution| |FIXED Target Milestone|--- |4.6.0 --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-29 10:55:49 UTC --- probably fixed by http://gcc.gnu.org/viewcvs?view=revision&revision=162187 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-06-29 10:56 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-03-08 14:55 [Bug c++/14482] New: hard to avoid -Weffc++ warnings with union members arnej at europe dot yahoo-inc dot com 2004-03-08 15:37 ` [Bug c++/14482] " pinskia at gcc dot gnu dot org 2004-04-28 19:06 ` pinskia at gcc dot gnu dot org [not found] <bug-14482-8084@http.gcc.gnu.org/bugzilla/> 2009-04-28 23:42 ` pinskia at gcc dot gnu dot org 2009-12-10 10:56 ` brian dot amberg at unibas dot ch 2009-12-10 13:04 ` paolo dot carlini at oracle dot com [not found] <bug-14482-4@http.gcc.gnu.org/bugzilla/> 2011-06-29 9:10 ` nocannedmeat at gmail dot com 2011-06-29 10:23 ` redi at gcc dot gnu.org 2011-06-29 10:56 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).