public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105265] New: temporary object not destructed causing memory leaks
@ 2022-04-13 14:01 jack.cui2 at foxmail dot com
  2022-04-13 14:15 ` [Bug c++/105265] " jack.cui2 at foxmail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: jack.cui2 at foxmail dot com @ 2022-04-13 14:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105265
           Summary: temporary object not destructed causing memory leaks
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jack.cui2 at foxmail dot com
  Target Milestone: ---

Created attachment 52801
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52801&action=edit
file that trigger the issue

Using built-in specs.
COLLECT_GCC=g++-11
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
11.1.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-11
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --disable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-11-YRKbe7/gcc-11-11.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-YRKbe7/gcc-11-11.1.0/debian/tmp-gcn/usr
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~18.04.1)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-g' '-std=c++17' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-linux-gnu/11/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE test_temporary.cpp -mtune=generic -march=x86-64
-std=c++17 -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fworking-directory
-fpch-preprocess -fasynchronous-unwind-tables -fstack-protector-strong
-Wformat-security -o a-test_temporary.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/11"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/11/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/11
 /usr/include/x86_64-linux-gnu/c++/11
 /usr/include/c++/11/backward
 /usr/lib/gcc/x86_64-linux-gnu/11/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-g' '-std=c++17' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-linux-gnu/11/cc1plus -fpreprocessed a-test_temporary.ii
-quiet -dumpdir a- -dumpbase test_temporary.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -g -Wall -Wextra -std=c++17 -version
-fno-strict-aliasing -fwrapv -fasynchronous-unwind-tables
-fstack-protector-strong -Wformat-security -o a-test_temporary.s
GNU C++17 (Ubuntu 11.1.0-1ubuntu1~18.04.1) version 11.1.0 (x86_64-linux-gnu)
        compiled by GNU C version 11.1.0, GMP version 6.1.2, MPFR version
4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

warning: GMP header version 6.1.2 differs from library version 6.2.0.
warning: MPFR header version 4.0.1 differs from library version 4.0.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++17 (Ubuntu 11.1.0-1ubuntu1~18.04.1) version 11.1.0 (x86_64-linux-gnu)
        compiled by GNU C version 11.1.0, GMP version 6.1.2, MPFR version
4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

warning: GMP header version 6.1.2 differs from library version 6.2.0.
warning: MPFR header version 4.0.1 differs from library version 4.0.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: fa8709337e38341bd283d8a4fb935104
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-g' '-std=c++17' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a-'
 as -v --64 -o a-test_temporary.o a-test_temporary.s
GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.34
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-g' '-std=c++17' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a.'
 /usr/lib/gcc/x86_64-linux-gnu/11/collect2 -plugin
/usr/lib/gcc/x86_64-linux-gnu/11/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
-plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id
--eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -pie -z now -z relro
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/11/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/11
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../.. a-test_temporary.o -lstdc++ -lm
-lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/11/crtendS.o
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crtn.o
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-g' '-std=c++17' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a.'

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

* [Bug c++/105265] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
@ 2022-04-13 14:15 ` jack.cui2 at foxmail dot com
  2022-04-13 14:23 ` jack.cui2 at foxmail dot com
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jack.cui2 at foxmail dot com @ 2022-04-13 14:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from jack <jack.cui2 at foxmail dot com> ---
#include <iostream>

using namespace std;

class Block
{
public:
    Block(int n) : data{new char[n]}, size{n}
    {
        cout << "Block ctor\n";
    }

    ~Block()
    {
        cout << "Block dtor\n";
        delete[] data;
    }

private:
    char* data;
    int size;
};

struct Cargo
{
    Block const& block;
};

int main()
{
    {
        Cargo* c = new Cargo{{4000}};
        cout << "main\n";
        delete c;
    }
    return 0;
}

Compile and run:
g++ -Wall -Wextra -fno-strict-aliasing -fwrapv -g -std=c++17

Output:
Block ctor
main

---------------------------
Issue: Block not destructed.

however, below forms are fine
{
    Cargo{{4000}};
    cout << "main";
}

{
    Cargo* c = new Cargo{Block{4000}};
    cout << "main";
    delete c;
}

They all output:

Block ctor
Block dtor
main

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

* [Bug c++/105265] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
  2022-04-13 14:15 ` [Bug c++/105265] " jack.cui2 at foxmail dot com
@ 2022-04-13 14:23 ` jack.cui2 at foxmail dot com
  2022-04-13 14:48 ` [Bug c++/105265] [9/10/11/12 Regression] " redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jack.cui2 at foxmail dot com @ 2022-04-13 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from jack <jack.cui2 at foxmail dot com> ---
Additional info: g++8.4 and clang++ 3.8 have no such issue

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

* [Bug c++/105265] [9/10/11/12 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
  2022-04-13 14:15 ` [Bug c++/105265] " jack.cui2 at foxmail dot com
  2022-04-13 14:23 ` jack.cui2 at foxmail dot com
@ 2022-04-13 14:48 ` redi at gcc dot gnu.org
  2022-04-13 15:09 ` ppalka at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-13 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
      Known to fail|                            |10.1.0, 10.3.0, 11.1.0,
                   |                            |11.2.0, 12.0, 9.3.0
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |wrong-code
      Known to work|                            |8.5.0, 9.2.0
   Last reconfirmed|                            |2022-04-13
                 CC|                            |jason at gcc dot gnu.org
   Target Milestone|---                         |9.5
            Summary|temporary object not        |[9/10/11/12 Regression]
                   |destructed causing memory   |temporary object not
                   |leaks                       |destructed causing memory
                   |                            |leaks

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Started with r279236

    PR c++/57082 - new X{} and private destructor.

    build_new_1 already passes tf_no_cleanup to build_value_init, but in this
    testcase we end up calling build_value_init by way of
    build_special_member_call, so we need to pass it to that function as well.

            * init.c (build_new_1): Also pass tf_no_cleanup to
            build_special_member_call.

Backported to gcc-9 as r279335

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

* [Bug c++/105265] [9/10/11/12 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (2 preceding siblings ...)
  2022-04-13 14:48 ` [Bug c++/105265] [9/10/11/12 Regression] " redi at gcc dot gnu.org
@ 2022-04-13 15:09 ` ppalka at gcc dot gnu.org
  2022-04-13 15:10 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-13 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

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

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The testcase seems to work correctly with trunk for me.

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

* [Bug c++/105265] [9/10/11/12 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (3 preceding siblings ...)
  2022-04-13 15:09 ` ppalka at gcc dot gnu.org
@ 2022-04-13 15:10 ` redi at gcc dot gnu.org
  2022-04-13 15:14 ` [Bug c++/105265] [9/10/11 " redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-13 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|12.0                        |
      Known to work|                            |12.0

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Ah yes, it was fixed by r12-1165

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

* [Bug c++/105265] [9/10/11 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (4 preceding siblings ...)
  2022-04-13 15:10 ` redi at gcc dot gnu.org
@ 2022-04-13 15:14 ` redi at gcc dot gnu.org
  2022-04-13 15:25 ` ppalka at gcc dot gnu.org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-13 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=100838

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
But not fixed on gcc-11 by the r11-8715 backport for PR100838, suggesting there
was an earlier change on trunk that affects it.

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

* [Bug c++/105265] [9/10/11 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (5 preceding siblings ...)
  2022-04-13 15:14 ` [Bug c++/105265] [9/10/11 " redi at gcc dot gnu.org
@ 2022-04-13 15:25 ` ppalka at gcc dot gnu.org
  2022-04-13 16:13 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-13 15:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #6)
> But not fixed on gcc-11 by the r11-8715 backport for PR100838, suggesting
> there was an earlier change on trunk that affects it.

Perhaps that's because of (from the r11-8715 commit message):

  For GCC 11, limit the changes to -fno-elide-constructors

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

* [Bug c++/105265] [9/10/11 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (6 preceding siblings ...)
  2022-04-13 15:25 ` ppalka at gcc dot gnu.org
@ 2022-04-13 16:13 ` jason at gcc dot gnu.org
  2022-04-13 16:17 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-13 16:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Probably makes sense to remove that extra condition on the 11 branch now.

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

* [Bug c++/105265] [9/10/11 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (7 preceding siblings ...)
  2022-04-13 16:13 ` jason at gcc dot gnu.org
@ 2022-04-13 16:17 ` jason at gcc dot gnu.org
  2022-04-14  0:22 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-13 16:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/105265] [9/10/11 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (8 preceding siblings ...)
  2022-04-13 16:17 ` jason at gcc dot gnu.org
@ 2022-04-14  0:22 ` cvs-commit at gcc dot gnu.org
  2022-04-14  6:31 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-14  0:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:019d6d4149ee97d55ce9efe4e5e470d38130cdeb

commit r12-8149-g019d6d4149ee97d55ce9efe4e5e470d38130cdeb
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 13 12:44:54 2022 -0400

    c++: add test [PR105265]

    This was fixed by r12-1165, but good to have a test that doesn't need
    -fno-elide-constructors.

            PR c++/105265
            PR c++/100838

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/initlist-new6.C: New test.

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

* [Bug c++/105265] [9/10/11 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (9 preceding siblings ...)
  2022-04-14  0:22 ` cvs-commit at gcc dot gnu.org
@ 2022-04-14  6:31 ` rguenth at gcc dot gnu.org
  2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-14  6:31 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/105265] [9/10/11 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (10 preceding siblings ...)
  2022-04-14  6:31 ` rguenth at gcc dot gnu.org
@ 2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
  2022-05-12 21:24 ` [Bug c++/105265] [9/10 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:728f97cf0431ff342beceea4f91afa1707133248

commit r11-9985-g728f97cf0431ff342beceea4f91afa1707133248
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 13 20:18:33 2022 -0400

    c++: temp cleanup in new [PR105265]

    The patch for PR100838 in GCC 11 was limited to -fno-elide-constructors for
    safety, but this testcase demonstrates that it's also needed without that
    flag.  So let's switch to the GCC 12 patch for PR100838.

            PR c++/105265
            PR c++/100838

    gcc/cp/ChangeLog:

            * call.c (build_user_type_conversion_1): Drop
            flag_elide_constructors check.
            (convert_like_internal): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/initlist-new6.C: New test.

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

* [Bug c++/105265] [9/10 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (11 preceding siblings ...)
  2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
@ 2022-05-12 21:24 ` cvs-commit at gcc dot gnu.org
  2022-05-13 18:24 ` [Bug c++/105265] [9 " cvs-commit at gcc dot gnu.org
  2022-05-13 18:26 ` jason at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:67f742536cbb60d5f8b7bba2cac0a141191e29af

commit r10-10727-g67f742536cbb60d5f8b7bba2cac0a141191e29af
Author: Jason Merrill <jason@redhat.com>
Date:   Mon May 31 12:36:25 2021 -0400

    c++: missing dtor with -fno-elide-constructors [PR100838]

    tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
    clear it for nested calls in build_over_call, but in this case both
    constructor calls came from convert_like, so we need to clear it in the
    recursive call as well.  This revealed that we were adding an extra
    ck_rvalue in direct-initialization cases where it was wrong.

            PR c++/100838
            PR c++/105265

    gcc/cp/ChangeLog:

            * call.c (convert_like_internal): Clear tf_no_cleanup when
            recursing.
            (build_user_type_conversion_1): Only add ck_rvalue if
            LOOKUP_ONLYCONVERTING.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/no-elide2.C: New test.
            * g++.dg/cpp0x/initlist-new6.C: New test.

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

* [Bug c++/105265] [9 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (12 preceding siblings ...)
  2022-05-12 21:24 ` [Bug c++/105265] [9/10 " cvs-commit at gcc dot gnu.org
@ 2022-05-13 18:24 ` cvs-commit at gcc dot gnu.org
  2022-05-13 18:26 ` jason at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 18:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:200d477d3cb1593dbaa7739c6270e0a7f6c564cf

commit r9-10178-g200d477d3cb1593dbaa7739c6270e0a7f6c564cf
Author: Jason Merrill <jason@redhat.com>
Date:   Mon May 31 12:36:25 2021 -0400

    c++: missing dtor with -fno-elide-constructors [PR100838]

    tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
    clear it for nested calls in build_over_call, but in this case both
    constructor calls came from convert_like, so we need to clear it in the
    recursive call as well.  This revealed that we were adding an extra
    ck_rvalue in direct-initialization cases where it was wrong.

            PR c++/100838
            PR c++/105265

    gcc/cp/ChangeLog:

            * call.c (convert_like_internal): Clear tf_no_cleanup when
            recursing.
            (build_user_type_conversion_1): Only add ck_rvalue if
            LOOKUP_ONLYCONVERTING.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/no-elide2.C: New test.
            * g++.dg/cpp0x/initlist-new6.C: New test.

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

* [Bug c++/105265] [9 Regression] temporary object not destructed causing memory leaks
  2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
                   ` (13 preceding siblings ...)
  2022-05-13 18:24 ` [Bug c++/105265] [9 " cvs-commit at gcc dot gnu.org
@ 2022-05-13 18:26 ` jason at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 18:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #13 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 9.5/10.4/11.4/12.

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

end of thread, other threads:[~2022-05-13 18:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 14:01 [Bug c++/105265] New: temporary object not destructed causing memory leaks jack.cui2 at foxmail dot com
2022-04-13 14:15 ` [Bug c++/105265] " jack.cui2 at foxmail dot com
2022-04-13 14:23 ` jack.cui2 at foxmail dot com
2022-04-13 14:48 ` [Bug c++/105265] [9/10/11/12 Regression] " redi at gcc dot gnu.org
2022-04-13 15:09 ` ppalka at gcc dot gnu.org
2022-04-13 15:10 ` redi at gcc dot gnu.org
2022-04-13 15:14 ` [Bug c++/105265] [9/10/11 " redi at gcc dot gnu.org
2022-04-13 15:25 ` ppalka at gcc dot gnu.org
2022-04-13 16:13 ` jason at gcc dot gnu.org
2022-04-13 16:17 ` jason at gcc dot gnu.org
2022-04-14  0:22 ` cvs-commit at gcc dot gnu.org
2022-04-14  6:31 ` rguenth at gcc dot gnu.org
2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
2022-05-12 21:24 ` [Bug c++/105265] [9/10 " cvs-commit at gcc dot gnu.org
2022-05-13 18:24 ` [Bug c++/105265] [9 " cvs-commit at gcc dot gnu.org
2022-05-13 18:26 ` 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).