From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 462A63858418; Sat, 5 Nov 2022 09:15:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 462A63858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667639725; bh=Mw5IFa3pNFvshRbNu50WJ5+T2SFSuVIyCjyw5D7ucko=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EA80BrDP6sAE+740fCr2M/IWG7WwJPT4YhYwYTxWa3P48/zpTQ5JKDJq4gMoXCQx8 YmMUm8Lh7c2L9/fsPNqEAW5F9qZdWFOM8lTjxsPDpDV2qMZQQyEpBh3ZsxjG6o17Cz aiQJdRfXDAiKrf7RS7edDOZkT2SatvhAYmAjO+CM= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107531] List of references calls destructors, add warning? Date: Sat, 05 Nov 2022 09:15:23 +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: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WORKSFORME 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: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107531 --- Comment #4 from Jonathan Wakely --- (In reply to nightstrike from comment #0) > Maybe adding something from -fsanitize=3Dundefined would be an option? There's nothing undefined in your example. But if you actually allocate and free resources, asan aborts on the double-free: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D1035874=3D=3DERROR: AddressSanitizer: attempting double-free on 0x602= 000000010 in thread T0: #0 0x7f69bd2bc088 in operator delete(void*, unsigned long) (/lib64/libasan.so.8+0xbc088) #1 0x401391 in S::~S() (/tmp/a.out+0x401391) #2 0x401247 in main (/tmp/a.out+0x401247) #3 0x7f69bca2950f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 #4 0x7f69bca295c8 in __libc_start_main_impl ../csu/libc-start.c:389 #5 0x4010f4 in _start (/tmp/a.out+0x4010f4) 0x602000000010 is located 0 bytes inside of 4-byte region [0x602000000010,0x602000000014) freed by thread T0 here: #0 0x7f69bd2bc088 in operator delete(void*, unsigned long) (/lib64/libasan.so.8+0xbc088) #1 0x401391 in S::~S() (/tmp/a.out+0x401391) #2 0x401577 in void f(S const&) (/tmp/a.out+0x401577) #3 0x40123b in main (/tmp/a.out+0x40123b) #4 0x7f69bca2950f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 previously allocated by thread T0 here: #0 0x7f69bd2bb188 in operator new(unsigned long) (/lib64/libasan.so.8+0xbb188) #1 0x4012e3 in S::S() (/tmp/a.out+0x4012e3) #2 0x40122f in main (/tmp/a.out+0x40122f) #3 0x7f69bca2950f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 SUMMARY: AddressSanitizer: double-free (/lib64/libasan.so.8+0xbc088) in operator delete(void*, unsigned long) =3D=3D1035874=3D=3DABORTING=