public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40239]  New: Aggregate initialization requires copy constructor
@ 2009-05-25  0:06 schaub-johannes at web dot de
  2009-08-25 15:44 ` [Bug c++/40239] " bangerth at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: schaub-johannes at web dot de @ 2009-05-25  0:06 UTC (permalink / raw)
  To: gcc-bugs

GCC 4.4.0 (and earlier) requires a copy constructor for elements that are not
explicitly initialized using a non-empty aggregate initializer list. Thus the
following fails

struct B { B() { } private: B(B const&); };
struct A { int a; B b; };

int main() { 
    A a = { 0 };
}

main.cpp: In function 'int main()':
main.cpp:1: error: 'B::B(const B&)' is private
main.cpp:5: error: within this context

The Standard says any not explicitly ininitialized element is
value-initialized. In the above sample, that should call the default
constructor. The copy constructor is required only when using an empty
aggregate initializer:


struct B { B() { } private: B(B const&); };
struct A { int a; B b; };

int main() { 
    A a = { };
}

In which case any element should be initialized from an expression of the form
T(), with T being the type of the element. GCC correctly rejects that example,
but incorrectly rejects the first example. 

Note that C++0x will make both examples valid (in the latest draft, at least),
and GCC should not reject any of them.


-- 
           Summary: Aggregate initialization requires copy constructor
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schaub-johannes at web dot de
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
@ 2009-08-25 15:44 ` bangerth at gmail dot com
  2010-01-11 15:53 ` dodji at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at gmail dot com @ 2009-08-25 15:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at gmail dot com  2009-08-25 15:44 -------
Confirmed. Not a regression.


-- 

bangerth at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at gmail dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2009-08-25 15:44:03
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
  2009-08-25 15:44 ` [Bug c++/40239] " bangerth at gmail dot com
@ 2010-01-11 15:53 ` dodji at gcc dot gnu dot org
  2010-01-12 11:00 ` dodji at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-01-11 15:53 UTC (permalink / raw)
  To: gcc-bugs



-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |dodji at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-08-25 15:44:03         |2010-01-11 15:53:43
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
  2009-08-25 15:44 ` [Bug c++/40239] " bangerth at gmail dot com
  2010-01-11 15:53 ` dodji at gcc dot gnu dot org
@ 2010-01-12 11:00 ` dodji at gcc dot gnu dot org
  2010-01-12 20:58 ` bangerth at gmail dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-01-12 11:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dodji at gcc dot gnu dot org  2010-01-12 11:00 -------
Posted a candidate fix to
http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00536.html

Please not that as this is a not a regression and it touches the core language
I doubt the patch is going to committed for 4.5


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
                   ` (2 preceding siblings ...)
  2010-01-12 11:00 ` dodji at gcc dot gnu dot org
@ 2010-01-12 20:58 ` bangerth at gmail dot com
  2010-01-12 21:49 ` dodji at seketeli dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at gmail dot com @ 2010-01-12 20:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bangerth at gmail dot com  2010-01-12 20:58 -------
Dodji,
thanks for the patch. As a matter of etiquette (I think we've had
this conversation with others in the past already): in your patch,
you mark the testcase as "Contributed by Dodji Seketeli", but in
fact the testcase is identically the one posted by the reporter of
this PR. It seems unfair that you take credit for it when it's really
by someone else.

That said, I think all of us C++ users really appreciate the number of
PRs you've taken care of recently!

Cheers
 W.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
                   ` (3 preceding siblings ...)
  2010-01-12 20:58 ` bangerth at gmail dot com
@ 2010-01-12 21:49 ` dodji at seketeli dot org
  2010-01-12 21:52 ` bangerth at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dodji at seketeli dot org @ 2010-01-12 21:49 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]



------- Comment #4 from dodji at seketeli dot org  2010-01-12 21:49 -------
Subject: Re:  Aggregate initialization requires copy
 constructor

Le mar. 12 janv. 2010 à 20:58:01 (-0000), bangerth at gmail dot com a écrit:
> As a matter of etiquette (I think we've had
> this conversation with others in the past already): in your patch,
> you mark the testcase as "Contributed by Dodji Seketeli", but in
> fact the testcase is identically the one posted by the reporter of
> this PR. It seems unfair that you take credit for it when it's really
> by someone else.

Oh, sorry. I didn't mean to piss people off. I thought that mentionning
the 'Origin' of the PR was the canonical way of designating where the test
case did come from, and the 'Contributed by 'would only designate the
person who committed the test case.

I will stop adding the 'Contributed by' line from now, and will remove
it from this patch. If you want, I can remove it from all the test cases
I did commit.

Sorry again.

> That said, I think all of us C++ users really appreciate the number of
> PRs you've taken care of recently!

Thank you. Though, in all fairness, I think those thanks should be
directed to my employer who allows me to work on those PRs.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
                   ` (4 preceding siblings ...)
  2010-01-12 21:49 ` dodji at seketeli dot org
@ 2010-01-12 21:52 ` bangerth at gmail dot com
  2010-01-12 23:34 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at gmail dot com @ 2010-01-12 21:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from bangerth at gmail dot com  2010-01-12 21:52 -------
(In reply to comment #4)
> I will stop adding the 'Contributed by' line from now, and will remove
> it from this patch. If you want, I can remove it from all the test cases
> I did commit.

I don't think that's necessary, I just meant to point this out. No worries.


> Thank you. Though, in all fairness, I think those thanks should be
> directed to my employer who allows me to work on those PRs.

I'm willing to extend my thanks to your employer while leaving them with you
as well :-)

W.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
                   ` (5 preceding siblings ...)
  2010-01-12 21:52 ` bangerth at gmail dot com
@ 2010-01-12 23:34 ` paolo dot carlini at oracle dot com
  2010-01-13  9:22 ` dodji at redhat dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-01-12 23:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2010-01-12 23:33 -------
Since we are talking of etiquette, and with the obvious caveats that my mother
language is italian + all the caveats about metaphorical uses of language, I
would also suggest keeping to a minimum the uses of "pissing" ;)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
                   ` (6 preceding siblings ...)
  2010-01-12 23:34 ` paolo dot carlini at oracle dot com
@ 2010-01-13  9:22 ` dodji at redhat dot com
  2010-04-07 15:12 ` dodji at gcc dot gnu dot org
  2010-04-07 15:13 ` dodji at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: dodji at redhat dot com @ 2010-01-13  9:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dodji at gcc dot gnu dot org  2010-01-13 09:21 -------
Subject: Re:  Aggregate initialization requires copy
 constructor

On Tue, Jan 12, 2010 at 11:33:56PM -0000, paolo dot carlini at oracle dot com
wrote:
> Since we are talking of etiquette, and with the obvious caveats that my mother
> language is italian + all the caveats about metaphorical uses of language, I
> would also suggest keeping to a minimum the uses of "pissing" ;)

Sorry, Paolo. I will avoid using that wording in the future.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
                   ` (7 preceding siblings ...)
  2010-01-13  9:22 ` dodji at redhat dot com
@ 2010-04-07 15:12 ` dodji at gcc dot gnu dot org
  2010-04-07 15:13 ` dodji at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-04-07 15:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from dodji at gcc dot gnu dot org  2010-04-07 15:12 -------
Subject: Bug 40239

Author: dodji
Date: Wed Apr  7 15:11:42 2010
New Revision: 158066

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158066
Log:
Fix PR c++/40239

gcc/cp/ChangeLog:
        PR c++/40239
        * typeck2.c (process_init_constructor_record):
        value-initialize members that are are not explicitely
        initialized.

gcc/testsuite/ChangeLog:
        PR c++/40239
        * g++.dg/init/aggr5.C: New test.
        * g++.dg/init/aggr5.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/init/aggr5.C
    trunk/gcc/testsuite/g++.dg/init/aggr6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/40239] Aggregate initialization requires copy constructor
  2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
                   ` (8 preceding siblings ...)
  2010-04-07 15:12 ` dodji at gcc dot gnu dot org
@ 2010-04-07 15:13 ` dodji at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-04-07 15:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from dodji at gcc dot gnu dot org  2010-04-07 15:12 -------
Fixed in 4.6 (trunk).


-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40239


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-04-07 15:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-25  0:06 [Bug c++/40239] New: Aggregate initialization requires copy constructor schaub-johannes at web dot de
2009-08-25 15:44 ` [Bug c++/40239] " bangerth at gmail dot com
2010-01-11 15:53 ` dodji at gcc dot gnu dot org
2010-01-12 11:00 ` dodji at gcc dot gnu dot org
2010-01-12 20:58 ` bangerth at gmail dot com
2010-01-12 21:49 ` dodji at seketeli dot org
2010-01-12 21:52 ` bangerth at gmail dot com
2010-01-12 23:34 ` paolo dot carlini at oracle dot com
2010-01-13  9:22 ` dodji at redhat dot com
2010-04-07 15:12 ` dodji at gcc dot gnu dot org
2010-04-07 15:13 ` dodji at gcc dot gnu dot 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).