public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members
@ 2006-12-07 17:51 gcc-bugzilla at kayari dot org
2006-12-07 18:03 ` [Bug c++/30111] " gcc-bugzilla at kayari dot org
` (10 more replies)
0 siblings, 11 replies; 13+ messages in thread
From: gcc-bugzilla at kayari dot org @ 2006-12-07 17:51 UTC (permalink / raw)
To: gcc-bugs
#include <iostream>
int main()
{
struct pod {
int i;
};
struct inherit : pod {
inherit() : pod() {}
};
struct compose {
compose() : p() {}
pod p;
};
inherit i;
compose c;
std::cout << i.i << std::endl;
std::cout << c.p.i << std::endl;
}
In both cases the pod object is explicitly value-initialized, which according
to 8.5para5 means that "every non-static data member ... is value-initialized"
compose::pod::i is value-initialised, inherit::i is not. This can be seen from
the values printed out for i.i and by using Purify.
Same result with GCC 4.1.1, 3.4.3, 3.3.4 on Solaris 9, GCC 3.4.3 on AIX 5/3
Valgrind is being weird so I can't test it on Linux, butI don't think it's
platform-dependent.
--
Summary: Value-initialization of POD base class doesn't
initialize members
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc-bugzilla at kayari dot org
GCC target triplet: sparc-sun-solaris2.9
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
@ 2006-12-07 18:03 ` gcc-bugzilla at kayari dot org
2006-12-08 7:27 ` rguenth at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: gcc-bugzilla at kayari dot org @ 2006-12-07 18:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from gcc-bugzilla at kayari dot org 2006-12-07 18:03 -------
Values printed out confirm it on Linux for 3.3.5 20050117 (prerelease) (SUSE
Linux), and official FSF 3.4.3, 4.0.1, 4.0.2, 4.1.1
N.B. I meant AIX 5.3, not 5/3
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
2006-12-07 18:03 ` [Bug c++/30111] " gcc-bugzilla at kayari dot org
@ 2006-12-08 7:27 ` rguenth at gcc dot gnu dot org
2006-12-08 7:35 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-12-08 7:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2006-12-08 07:27 -------
As compose is not POD it initializes p in the constructor. For inherit the
constructor of p is called which - surprise - as a POD constructor does
nothing.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
2006-12-07 18:03 ` [Bug c++/30111] " gcc-bugzilla at kayari dot org
2006-12-08 7:27 ` rguenth at gcc dot gnu dot org
@ 2006-12-08 7:35 ` pinskia at gcc dot gnu dot org
2006-12-08 10:36 ` gcc-bugzilla at kayari dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-12-08 7:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-12-08 07:34 -------
(In reply to comment #2)
> As compose is not POD it initializes p in the constructor. For inherit the
> constructor of p is called which - surprise - as a POD constructor does
> nothing.
Actually read the standard, it does, see 8.5/7 and 8.5/5 the second part about
default initializer.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (2 preceding siblings ...)
2006-12-08 7:35 ` pinskia at gcc dot gnu dot org
@ 2006-12-08 10:36 ` gcc-bugzilla at kayari dot org
2006-12-30 19:40 ` gdr at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: gcc-bugzilla at kayari dot org @ 2006-12-08 10:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from gcc-bugzilla at kayari dot org 2006-12-08 10:36 -------
Richard, there's no difference between pod() and p() in this case, both are
value-initialisations of a POD class, therefore all non-static data members
should be value-initialised. I cited 8.5p5 for good reason :)
Sun CC 6.1 and 8 and IBM xlC 6 get this right.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (3 preceding siblings ...)
2006-12-08 10:36 ` gcc-bugzilla at kayari dot org
@ 2006-12-30 19:40 ` gdr at gcc dot gnu dot org
2007-06-10 2:18 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: gdr at gcc dot gnu dot org @ 2006-12-30 19:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from gdr at gcc dot gnu dot org 2006-12-30 19:40 -------
Thsi is indeed a bug in g++.
the pod() in inherit() is a value-initialization, not a call to
default-constructor.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-12-30 19:40:22
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (4 preceding siblings ...)
2006-12-30 19:40 ` gdr at gcc dot gnu dot org
@ 2007-06-10 2:18 ` pinskia at gcc dot gnu dot org
2007-06-18 1:37 ` jwakely dot gcc at gmail dot com
` (4 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-10 2:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2007-06-10 02:18 -------
*** Bug 32141 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |james dot kanze at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (5 preceding siblings ...)
2007-06-10 2:18 ` pinskia at gcc dot gnu dot org
@ 2007-06-18 1:37 ` jwakely dot gcc at gmail dot com
2008-02-04 16:07 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2007-06-18 1:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jwakely dot gcc at gmail dot com 2007-06-18 01:36 -------
Confirmed on x86-linux, sparc-solaris and ppc-AIX so I've removed the Target.
Also verified that valgrind shows the uninitialised memory reads.
This bug breaks common idioms like:
template <typename A, typename B>
struct compressed_pair : A {
compressed_pair() : A(), second_() { }
A& first() { return *this; }
B& second() { return second_; }
private:
B second_;
};
--
jwakely dot gcc at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
GCC target triplet|sparc-sun-solaris2.9 |
Known to fail| |4.2.0 4.1.1 3.4.3 3.3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (6 preceding siblings ...)
2007-06-18 1:37 ` jwakely dot gcc at gmail dot com
@ 2008-02-04 16:07 ` rguenth at gcc dot gnu dot org
2009-02-11 5:35 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-04 16:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2008-02-04 16:06 -------
Jason is this the same issue as PR33916 you fixed? (Your fix didn't change
the outcome of this PR though)
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (7 preceding siblings ...)
2008-02-04 16:07 ` rguenth at gcc dot gnu dot org
@ 2009-02-11 5:35 ` jason at gcc dot gnu dot org
2009-02-11 22:39 ` jason at gcc dot gnu dot org
2009-02-11 22:50 ` jason at gcc dot gnu dot org
10 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-02-11 5:35 UTC (permalink / raw)
To: gcc-bugs
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2006-12-30 19:40:22 |2009-02-11 05:35:35
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (8 preceding siblings ...)
2009-02-11 5:35 ` jason at gcc dot gnu dot org
@ 2009-02-11 22:39 ` jason at gcc dot gnu dot org
2009-02-11 22:50 ` jason at gcc dot gnu dot org
10 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-02-11 22:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jason at gcc dot gnu dot org 2009-02-11 22:38 -------
Subject: Bug 30111
Author: jason
Date: Wed Feb 11 22:38:37 2009
New Revision: 144112
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144112
Log:
PR c++/30111
* init.c (build_value_init_noctor): Split out from...
(build_value_init): ...here.
(expand_aggr_init_1): Handle value-initialization.
* cp-tree.h: Add declaration.
* class.c (type_has_user_provided_constructor):
Handle non-class arguments.
Added:
trunk/gcc/testsuite/g++.dg/init/value7.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/class.c
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/init.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
` (9 preceding siblings ...)
2009-02-11 22:39 ` jason at gcc dot gnu dot org
@ 2009-02-11 22:50 ` jason at gcc dot gnu dot org
10 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-02-11 22:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jason at gcc dot gnu dot org 2009-02-11 22:50 -------
Fixed for 4.4.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/30111] Value-initialization of POD base class doesn't initialize members
[not found] <bug-30111-4@http.gcc.gnu.org/bugzilla/>
@ 2014-02-16 10:02 ` jackie.rosen at hushmail dot com
0 siblings, 0 replies; 13+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 10:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
Jackie Rosen <jackie.rosen at hushmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jackie.rosen at hushmail dot com
--- Comment #11 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Marked for reference. Resolved as fixed @bugzilla.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-02-16 10:02 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-07 17:51 [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members gcc-bugzilla at kayari dot org
2006-12-07 18:03 ` [Bug c++/30111] " gcc-bugzilla at kayari dot org
2006-12-08 7:27 ` rguenth at gcc dot gnu dot org
2006-12-08 7:35 ` pinskia at gcc dot gnu dot org
2006-12-08 10:36 ` gcc-bugzilla at kayari dot org
2006-12-30 19:40 ` gdr at gcc dot gnu dot org
2007-06-10 2:18 ` pinskia at gcc dot gnu dot org
2007-06-18 1:37 ` jwakely dot gcc at gmail dot com
2008-02-04 16:07 ` rguenth at gcc dot gnu dot org
2009-02-11 5:35 ` jason at gcc dot gnu dot org
2009-02-11 22:39 ` jason at gcc dot gnu dot org
2009-02-11 22:50 ` jason at gcc dot gnu dot org
[not found] <bug-30111-4@http.gcc.gnu.org/bugzilla/>
2014-02-16 10:02 ` jackie.rosen at hushmail dot com
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).