* [Bug c++/33916] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
@ 2007-10-31 20:08 ` crowl at google dot com
2007-11-01 2:17 ` gdr at gcc dot gnu dot org
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: crowl at google dot com @ 2007-10-31 20:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from crowl at google dot com 2007-10-31 20:08 -------
The wording in the C++ standard working paper is as follows:
8.5 Initializers [dcl.init]
-8- An object whose initializer is an empty set of parentheses, i.e.,
(), shall be value-initialized.
Therefore, in <<< Stats my_stats = Stats(); >>>, the temporary object
is value-initialized and then my_stats is copy-constructed.
-5- To value-initialize an object of type T means:
-- if T is a non-union class type without a user-provided
constructor, then every non-static data member and base-class
component of T is value-initialized;93)
93) Value-initialization for such a class object may be
implemented by zero-initializing the object and then calling
the default constructor.
-- if T is an array type, then each element is value-initialized;
-- otherwise, the object is zero-initialized
Therefore, the temporary should be zero-initialized and the resulting
copy should copy zeros. So, I conclude that gcc 4.2.1 is in error.
(I suspect the compiler already eliminates the copy.)
I suspect the problem arose in someone thinking that the zero
initialization in front of a call to a default constructor was
redundant. Alas, it is not. It is redundant only if the constructor
initializes all fields, which is generally unknowable, though the
compiler could determine so for many types and constructors.
--
crowl at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |crowl at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
2007-10-31 20:08 ` [Bug c++/33916] " crowl at google dot com
@ 2007-11-01 2:17 ` gdr at gcc dot gnu dot org
2007-12-11 0:04 ` [Bug c++/33916] [4.2/4.3 Regression] " janis at gcc dot gnu dot org
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: gdr at gcc dot gnu dot org @ 2007-11-01 2:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gdr at gcc dot gnu dot org 2007-11-01 02:16 -------
I concur with Lawrence' analysis.
I was bitten by this bug myself in my own code.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-11-01 02:16:55
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
2007-10-31 20:08 ` [Bug c++/33916] " crowl at google dot com
2007-11-01 2:17 ` gdr at gcc dot gnu dot org
@ 2007-12-11 0:04 ` janis at gcc dot gnu dot org
2007-12-11 0:17 ` pinskia at gcc dot gnu dot org
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: janis at gcc dot gnu dot org @ 2007-12-11 0:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from janis at gcc dot gnu dot org 2007-12-11 00:03 -------
A regression hunt on powerpc-linux identified this patch:
http://gcc.gnu.org/viewcvs?view=rev&rev=117834
r117834 | mmitchel | 2006-10-17 22:35:29 +0000 (Tue, 17 Oct 2006)
--
janis at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mmitchel at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (2 preceding siblings ...)
2007-12-11 0:04 ` [Bug c++/33916] [4.2/4.3 Regression] " janis at gcc dot gnu dot org
@ 2007-12-11 0:17 ` pinskia at gcc dot gnu dot org
2007-12-12 20:55 ` mmitchel at gcc dot gnu dot org
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-12-11 0:17 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Target Milestone|--- |4.2.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (3 preceding siblings ...)
2007-12-11 0:17 ` pinskia at gcc dot gnu dot org
@ 2007-12-12 20:55 ` mmitchel at gcc dot gnu dot org
2008-01-02 23:49 ` mmitchel at gcc dot gnu dot org
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-12-12 20:55 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (4 preceding siblings ...)
2007-12-12 20:55 ` mmitchel at gcc dot gnu dot org
@ 2008-01-02 23:49 ` mmitchel at gcc dot gnu dot org
2008-01-07 19:21 ` mmitchel at gcc dot gnu dot org
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2008-01-02 23:49 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mmitchel at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2007-12-10 18:15:07 |2008-01-02 23:32:42
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (5 preceding siblings ...)
2008-01-02 23:49 ` mmitchel at gcc dot gnu dot org
@ 2008-01-07 19:21 ` mmitchel at gcc dot gnu dot org
2008-01-07 19:47 ` crowl at google dot com
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2008-01-07 19:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from mmitchel at gcc dot gnu dot org 2008-01-07 18:13 -------
I still agree that we should fix this -- but it is worth noting that
value-initialization did not exist in C++98. I believe that the current G++
behavior conforms to the original C++98 specification.
Does anyone know if this change was in C++98 TC1? Or not until C++0x?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (6 preceding siblings ...)
2008-01-07 19:21 ` mmitchel at gcc dot gnu dot org
@ 2008-01-07 19:47 ` crowl at google dot com
2008-01-22 21:23 ` steven at gcc dot gnu dot org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: crowl at google dot com @ 2008-01-07 19:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from crowl at google dot com 2008-01-07 18:58 -------
Subject: Re: [4.2/4.3 Regression] Default constructor fails to initialize
array members
Value initialization was in C++98 TC1 (2003) as a result of core issue 178.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (7 preceding siblings ...)
2008-01-07 19:47 ` crowl at google dot com
@ 2008-01-22 21:23 ` steven at gcc dot gnu dot org
2008-01-25 16:54 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: steven at gcc dot gnu dot org @ 2008-01-22 21:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from steven at gcc dot gnu dot org 2008-01-22 21:01 -------
There is some discussion about this bug in the following thread on gcc-patches:
http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00326.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (8 preceding siblings ...)
2008-01-22 21:23 ` steven at gcc dot gnu dot org
@ 2008-01-25 16:54 ` rguenth at gcc dot gnu dot org
2008-02-01 17:01 ` jsm28 at gcc dot gnu dot org
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 16:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2008-01-25 15:46 -------
Jason, can you coordinate with Mark and help with the remaining P1 C++
regressions?
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (9 preceding siblings ...)
2008-01-25 16:54 ` rguenth at gcc dot gnu dot org
@ 2008-02-01 17:01 ` jsm28 at gcc dot gnu dot org
2008-02-04 3:30 ` jason at gcc dot gnu dot org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-02-01 17:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jsm28 at gcc dot gnu dot org 2008-02-01 16:55 -------
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.2.3 |4.2.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2/4.3 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (10 preceding siblings ...)
2008-02-01 17:01 ` jsm28 at gcc dot gnu dot org
@ 2008-02-04 3:30 ` jason at gcc dot gnu dot org
2008-02-04 12:15 ` [Bug c++/33916] [4.2 " rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-02-04 3:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jason at gcc dot gnu dot org 2008-02-04 03:29 -------
Subject: Bug 33916
Author: jason
Date: Mon Feb 4 03:28:53 2008
New Revision: 132088
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132088
Log:
PR c++/33916
* cp/init.c (build_value_init_1): New function.
(build_value_init): New function.
* cp/typeck2.c (build_functional_cast): Call it.
* cp/cp-gimplify.c (cp_gimplify_init_expr): Handle its output.
* cp/cp-tree.h (TYPE_HAS_USER_CONSTRUCTOR): Rename from
TYPE_HAS_CONSTRUCTOR.
* cp/class.c (finish_struct_bits,
maybe_warn_about_overly_private_class,
add_implicitly_declared_members): Adjust.
(check_field_decls): Adjust. Remove warnings about reference/const
in class without constructor.
(check_bases_and_members): Adjust. Give those warnings here instead.
* cp/decl.c (fixup_anonymous_aggr): Adjust.
(check_initializer): Adjust, clarify logic slightly.
(grok_special_member_properties): Adjust, only set if user-provided.
* cp/rtti.c (create_tinfo_types): Don't set.
* cp/cvt.c (ocp_convert): Remove exception for vtable_entry_type et al.
Use same_type_ignoring_top_level_qualifiers_p.
* cp/pt.c (check_explicit_specialization): Adjust.
(instantiate_class_template): Adjust.
* print-tree.c (print_node) [CONSTRUCTOR]: Print elements.
Added:
trunk/gcc/testsuite/g++.dg/init/value1.C
trunk/gcc/testsuite/g++.dg/warn/Wextra-1.C
trunk/gcc/testsuite/g++.dg/warn/Wextra-2.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/class.c
trunk/gcc/cp/cp-gimplify.c
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/cvt.c
trunk/gcc/cp/decl.c
trunk/gcc/cp/init.c
trunk/gcc/cp/pt.c
trunk/gcc/cp/rtti.c
trunk/gcc/cp/typeck2.c
trunk/gcc/print-tree.c
trunk/gcc/testsuite/g++.dg/init/ctor8.C
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (11 preceding siblings ...)
2008-02-04 3:30 ` jason at gcc dot gnu dot org
@ 2008-02-04 12:15 ` rguenth at gcc dot gnu dot org
2008-02-12 6:39 ` jason at gcc dot gnu dot org
2008-02-12 6:42 ` jason at gcc dot gnu dot org
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-04 12:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from rguenth at gcc dot gnu dot org 2008-02-04 12:15 -------
Fixed on the trunk.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.3.0
Summary|[4.2/4.3 Regression] Default|[4.2 Regression] Default
|constructor fails to |constructor fails to
|initialize array members |initialize array members
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (12 preceding siblings ...)
2008-02-04 12:15 ` [Bug c++/33916] [4.2 " rguenth at gcc dot gnu dot org
@ 2008-02-12 6:39 ` jason at gcc dot gnu dot org
2008-02-12 6:42 ` jason at gcc dot gnu dot org
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-02-12 6:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jason at gcc dot gnu dot org 2008-02-12 06:38 -------
Subject: Bug 33916
Author: jason
Date: Tue Feb 12 06:37:34 2008
New Revision: 132254
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132254
Log:
PR c++/34094
* decl2.c (cp_write_global_declarations): Don't write out static
data members with DECL_IN_AGGR_P set.
PR c++/33916
* Revert:
2006-10-17 Mark Mitchell <mark@codesourcery.com>
PR c++/29039
* typeck2.c (build_functional_cast): Don't zero-initialize
non-PODs; instead, call their constructors.
Removed:
branches/gcc-4_2-branch/gcc/testsuite/g++.dg/init/ctor8.C
Modified:
branches/gcc-4_2-branch/gcc/cp/ChangeLog
branches/gcc-4_2-branch/gcc/cp/decl2.c
branches/gcc-4_2-branch/gcc/cp/typeck2.c
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/33916] [4.2 Regression] Default constructor fails to initialize array members
2007-10-26 21:06 [Bug c++/33916] New: Default constructor fails to initialize array members mec at google dot com
` (13 preceding siblings ...)
2008-02-12 6:39 ` jason at gcc dot gnu dot org
@ 2008-02-12 6:42 ` jason at gcc dot gnu dot org
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-02-12 6:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jason at gcc dot gnu dot org 2008-02-12 06:41 -------
Fixed for 4.2.4 by reverting part of Mark's patch for PR 29039.
--
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=33916
^ permalink raw reply [flat|nested] 16+ messages in thread