public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66501] New: Default move assignment does not move array members
@ 2015-06-11  6:48 john.lindgren at aol dot com
  2015-06-11  8:07 ` [Bug c++/66501] [4.9/5/6 Regression] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: john.lindgren at aol dot com @ 2015-06-11  6:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

            Bug ID: 66501
           Summary: Default move assignment does not move array members
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: john.lindgren at aol dot com
  Target Milestone: ---

In the following code, main() should return 0 (and did with GCC 4.8.2).  With
GCC 5.1.0, main() instead returns 2.  It seems that the compiler-generated
Container::operator=(Container&&) does not call Object::operator=(Object&&) as
it ought.  So the line "container=Container()" line does not subtract 2 from
total_size as would be expected.

int total_size;

struct Object
{
    int size = 0;

    Object () = default;

    ~Object () {
        total_size -= size;
    }

    Object (const Object &) = delete;
    Object & operator= (const Object &) = delete;

    Object (Object && b) {
        size = b.size;
        b.size = 0;
    }

    Object & operator= (Object && b) {
        if (this != & b) {
            total_size -= size;
            size = b.size;
            b.size = 0;
        }
        return * this;
    }

    void grow () {
        size ++;
        total_size ++;
    }
};

struct Container {
    Object objects[2];
};

int main (void)
{
    Container container;

    // grow some objects in the container
    for (auto & object : container.objects)
        object.grow ();

    // now empty it
    container = Container ();

    return total_size;
}

gcc -v gives:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-5-20150519/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --enable-multilib --disable-werror
--enable-checking=release --with-default-libstdcxx-abi=c++98
Thread model: posix
gcc version 5.1.0 (GCC)


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

* [Bug c++/66501] [4.9/5/6 Regression] Default move assignment does not move array members
  2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
@ 2015-06-11  8:07 ` redi at gcc dot gnu.org
  2015-06-12 17:01 ` daniel.kruegler at googlemail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2015-06-11  8:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-06-11
      Known to work|                            |4.8.3
            Summary|Default move assignment     |[4.9/5/6 Regression]
                   |does not move array members |Default move assignment
                   |                            |does not move array members
     Ever confirmed|0                           |1
      Known to fail|                            |4.9.2, 5.1.0, 6.0


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

* [Bug c++/66501] [4.9/5/6 Regression] Default move assignment does not move array members
  2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
  2015-06-11  8:07 ` [Bug c++/66501] [4.9/5/6 Regression] " redi at gcc dot gnu.org
@ 2015-06-12 17:01 ` daniel.kruegler at googlemail dot com
  2015-06-23 14:09 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2015-06-12 17:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
The problem still exists in gcc HEAD 6.0.0 20150611 (experimental)
>From gcc-bugs-return-488893-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jun 12 17:05:15 2015
Return-Path: <gcc-bugs-return-488893-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 76016 invoked by alias); 12 Jun 2015 17:05:15 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 75564 invoked by uid 48); 12 Jun 2015 17:05:10 -0000
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66517] [5 Regression] [C++11] sorry, unimplemented: unexpected AST of kind type_decl
Date: Fri, 12 Jun 2015 17:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.1.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: daniel.kruegler at googlemail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-66517-4-k7gmp0cnp2@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66517-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66517-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-06/txt/msg01225.txt.bz2
Content-length: 533

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66517

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
Seems to be fixed in gcc HEAD 6.0.0 20150611 (experimental)
>From gcc-bugs-return-488894-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jun 12 17:53:33 2015
Return-Path: <gcc-bugs-return-488894-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 129246 invoked by alias); 12 Jun 2015 17:53:33 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 128877 invoked by uid 48); 12 Jun 2015 17:53:29 -0000
From: "singhai at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/66301] internal compiler error when using -fopt-info
Date: Fri, 12 Jun 2015 17:53:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: debug
X-Bugzilla-Version: 5.1.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: singhai at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-66301-4-qCrU7Dymam@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66301-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66301-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-06/txt/msg01226.txt.bz2
Content-length: 595

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf301

Sharad Singhai <singhai at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |singhai at gcc dot gnu.org

--- Comment #5 from Sharad Singhai <singhai at gcc dot gnu.org> ---
Sorry, I didn't get time to look at this. Yes, this is the right fix in the
interim as old and new style of dumping cannot be mixed.

Another fix would require converting this and other passes to the new style.


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

* [Bug c++/66501] [4.9/5/6 Regression] Default move assignment does not move array members
  2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
  2015-06-11  8:07 ` [Bug c++/66501] [4.9/5/6 Regression] " redi at gcc dot gnu.org
  2015-06-12 17:01 ` daniel.kruegler at googlemail dot com
@ 2015-06-23 14:09 ` jason at gcc dot gnu.org
  2015-06-24 15:40 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-23 14:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Jun 23 14:08:25 2015
New Revision: 224843

URL: https://gcc.gnu.org/viewcvs?rev=224843&root=gcc&view=rev
Log:
        PR c++/66501
        * class.c (type_has_nontrivial_assignment): New.
        * init.c (build_vec_init): Use it.
        * cp-tree.h: Declare it.
        * method.c (trivial_fn_p): Templates aren't trivial.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/rv-array1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/init.c
    trunk/gcc/cp/method.c


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

* [Bug c++/66501] [4.9/5/6 Regression] Default move assignment does not move array members
  2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
                   ` (2 preceding siblings ...)
  2015-06-23 14:09 ` jason at gcc dot gnu.org
@ 2015-06-24 15:40 ` jason at gcc dot gnu.org
  2015-06-24 15:41 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-24 15:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Jun 24 15:40:08 2015
New Revision: 224904

URL: https://gcc.gnu.org/viewcvs?rev=224904&root=gcc&view=rev
Log:
        PR c++/66501
        * class.c (type_has_nontrivial_assignment): Remove.
        * cp-tree.h: Remove declaration.
        * init.c (vec_copy_assign_is_trivial): New.
        (build_vec_init): Use it.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/init.c


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

* [Bug c++/66501] [4.9/5/6 Regression] Default move assignment does not move array members
  2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
                   ` (3 preceding siblings ...)
  2015-06-24 15:40 ` jason at gcc dot gnu.org
@ 2015-06-24 15:41 ` jason at gcc dot gnu.org
  2015-06-24 15:42 ` jason at gcc dot gnu.org
  2015-06-24 20:01 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-24 15:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Jun 24 15:41:10 2015
New Revision: 224905

URL: https://gcc.gnu.org/viewcvs?rev=224905&root=gcc&view=rev
Log:
        PR c++/66501
        * init.c (vec_copy_assign_is_trivial): New.
        (build_vec_init): Use it.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/rv-array1.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/init.c


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

* [Bug c++/66501] [4.9/5/6 Regression] Default move assignment does not move array members
  2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
                   ` (4 preceding siblings ...)
  2015-06-24 15:41 ` jason at gcc dot gnu.org
@ 2015-06-24 15:42 ` jason at gcc dot gnu.org
  2015-06-24 20:01 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-24 15:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Jun 24 15:41:52 2015
New Revision: 224906

URL: https://gcc.gnu.org/viewcvs?rev=224906&root=gcc&view=rev
Log:
        PR c++/66501
        * init.c (vec_copy_assign_is_trivial): New.
        (build_vec_init): Use it.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/rv-array1.C
Modified:
    branches/gcc-4_9-branch/gcc/cp/ChangeLog
    branches/gcc-4_9-branch/gcc/cp/init.c


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

* [Bug c++/66501] [4.9/5/6 Regression] Default move assignment does not move array members
  2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
                   ` (5 preceding siblings ...)
  2015-06-24 15:42 ` jason at gcc dot gnu.org
@ 2015-06-24 20:01 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-06-24 20:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2015-06-24 20:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-11  6:48 [Bug c++/66501] New: Default move assignment does not move array members john.lindgren at aol dot com
2015-06-11  8:07 ` [Bug c++/66501] [4.9/5/6 Regression] " redi at gcc dot gnu.org
2015-06-12 17:01 ` daniel.kruegler at googlemail dot com
2015-06-23 14:09 ` jason at gcc dot gnu.org
2015-06-24 15:40 ` jason at gcc dot gnu.org
2015-06-24 15:41 ` jason at gcc dot gnu.org
2015-06-24 15:42 ` jason at gcc dot gnu.org
2015-06-24 20:01 ` jason 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).