From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 8AA333858C78 for ; Fri, 17 Feb 2023 11:43:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8AA333858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x32c.google.com with SMTP id z12-20020a1c4c0c000000b003e21e018039so2234883wmf.3 for ; Fri, 17 Feb 2023 03:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=LFHzmN9S4v1sH4FFWct0C7VhZ+raZ1uC2e4pXCviHFg=; b=YUoDx8zgiroNzRs4RScKqfRJUZq8OVwrm7M71boXqUyOTyDcHM6Pr5AF2gmh2ebDdL 869Plp9qBOTTBgPag/jNbPUo7Tx3MmZ7HnOqCt2/hRaRBqOVv+y2pKZEU5v7PREtYdfC o71zAIfffIiY5dOU7JIMWTYprEWcDNYB4WNAEfNsT5mG6mfChDVAOS7WoHym7B+vPlZx YEQNGmh+3J2FP/TLsw9CG6BLLbNnvhSo/gEl6bqguy2cY/VC/KO6bUcsh6uxBMLSg3B/ NHPPGDUuvqEElK1g44rJ0owqNvIoMDLTAGMTzIEwuvya4tG7dzbslq/fnP7IVFfax3rZ p0Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=LFHzmN9S4v1sH4FFWct0C7VhZ+raZ1uC2e4pXCviHFg=; b=2AhGVtld7lDA4E3N82KBrgjjBlYqlhInOMxzZO0cIZwPV9jS9ZSh51H/IFk7eT0v+U CshFkhAuxiLTMzqVmbxm2JoLF4FWB9nst29CB1vau6X5f5/SLIfzeeNWAKOWY44p3KNY V7qstcwgqiwmbAd+Cr0n2OazsCOJ8J8YHS5mkxmEsLJCqGmKgNy7i71AH89bRNnTUt3o B/QVyW0GWKF7fwLLz6QVdL/0Be1fuLPyP4Cg7ReQLLg8WiADTyltQdHRf9YuHEtNEz5L S+WEmt85TTpw5TRGLi8sCyb0xRoYk8ksjOFgOGQGz0i5uZJA47Yg/ONU8sJF3CtJdLl7 K81g== X-Gm-Message-State: AO0yUKW1inMrqAKBs4CfKp8TdEM5SsTWF86WJ2W4rZKRBmjPWlb2HkX8 pmsrOIsZ0y4cBV66lPjt+cY= X-Google-Smtp-Source: AK7set/wl/3jVKsBcDofFt9UxAuRIiAG5/FHmukNtbXuJIeJN27N1jHPp2qwO4GAKPHbqiS1dPRTqg== X-Received: by 2002:a05:600c:1d97:b0:3e2:1dac:b071 with SMTP id p23-20020a05600c1d9700b003e21dacb071mr2738334wms.13.1676634236231; Fri, 17 Feb 2023 03:43:56 -0800 (PST) Received: from [192.168.0.160] ([170.253.36.171]) by smtp.gmail.com with ESMTPSA id hn30-20020a05600ca39e00b003db03725e86sm4747211wmb.8.2023.02.17.03.43.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Feb 2023 03:43:55 -0800 (PST) Message-ID: <6aaff906-1c3b-c625-7d5c-68c56583257d@gmail.com> Date: Fri, 17 Feb 2023 12:43:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: Missed warning (-Wuse-after-free) Content-Language: en-US To: Jonathan Wakely Cc: David Malcolm , GCC , Iker Pedrosa , Siddhesh Poyarekar , Florian Weimer , Sam James , Paul Eggert , Michael Kerrisk , Martin Uecker , =?UTF-8?B?SuKCkeKCmeKCmyBHdXN0ZWR0?= , Yann Droneaud References: <8ed6d28c-69dc-fed8-5ab5-99f685f06fac@gmail.com> <38e7e994a81d2a18666404dbaeb556f3508a6bd6.camel@redhat.com> From: Alejandro Colomar In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------0dkCB1hict2ujbBrgGILs0aI" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------0dkCB1hict2ujbBrgGILs0aI Content-Type: multipart/mixed; boundary="------------IOSLw8qvzjfmHT0mFSdkpcbK"; protected-headers="v1" From: Alejandro Colomar To: Jonathan Wakely Cc: David Malcolm , GCC , Iker Pedrosa , Siddhesh Poyarekar , Florian Weimer , Sam James , Paul Eggert , Michael Kerrisk , Martin Uecker , =?UTF-8?B?SuKCkeKCmeKCmyBHdXN0ZWR0?= , Yann Droneaud Message-ID: <6aaff906-1c3b-c625-7d5c-68c56583257d@gmail.com> Subject: Re: Missed warning (-Wuse-after-free) References: <8ed6d28c-69dc-fed8-5ab5-99f685f06fac@gmail.com> <38e7e994a81d2a18666404dbaeb556f3508a6bd6.camel@redhat.com> In-Reply-To: --------------IOSLw8qvzjfmHT0mFSdkpcbK Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Jonathan, On 2/17/23 12:24, Jonathan Wakely wrote: > Please be aware that in C++ it's implementation-defined, not undefined.= >=20 > That means that an implementation without trap representations for poin= ters > can choose to make it behave just like using (uintptr_t)p. (uintptr_t)p is defined (I believe) for C <=3D C17. However, as noted in= my last email, even that is UB for C2x. Of course, UB means that the compil= er might make it defined, but as Martin suggested, that's might have its own= issues. >=20 > https://cplusplus.github.io/CWG/issues/1438.html > https://cplusplus.github.io/CWG/issues/623.html > https://cplusplus.github.io/CWG/issues/616.html > https://cplusplus.github.io/CWG/issues/312.html >=20 > We could still warn in C++ (because the code isn't portable) but I woul= d > strongly suggest we don't influence C++ codegen based on deallocated > pointers being undefined. I don't think gcc supports any targets with > trapping pointers, and there are quite enough sources of UB already. We= > don't need to create traps for users where there are no traps for point= ers > :-) I would warn in C++ too, as some of that code might be in interfaces that= should be compatible with C. Maybe not include it in -Wextra in C++ (but= include it in C's -Wextra)... Cheers, Alex --=20 GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5 --------------IOSLw8qvzjfmHT0mFSdkpcbK-- --------------0dkCB1hict2ujbBrgGILs0aI Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmPvaHoACgkQnowa+77/ 2zK/jRAAqsUR7fLWnG0K7JqZnf6GnPyYmB7I8ffyrSRlNl+PZdMOLSafa8UEzDRc cOgQpoaAe8WJOP3gAA5r2xZJYHVAhK/BtaiP5KCfdl7HeDMhMo3U1mKBBgoaEc7h d03bBoPUxn+t/LVbiq6iItNHTX47FYnJv7tyIAbXDULdBa8Ac8EQrXV1sf9x0BHR 5lGtIVFajWup5983k+gv4dNXPbY4HURB/fnF0SS5fCN/i5o2h4zokfR6j2kD/phC hfYwUQbIlI3brAPfT8oVHlAbyHSWV3I9YCLhOSks5t6wHnEaFxJQHSfOGLPFuUdV pXIL/8h1n8jPT2T5J5vSNZEbP2WMnyGtiywu79mC9jxkU0gcwqnMho/hKewPOAiu Z8GpyoUIyeI6H7NQSPgsQRy/InThppp0LytWFtqmyq64FAcTgDrORaAHfdmwlZYI AMjVVYFfoWg+pc9hASX8/Kit6AnlLLOzjddOrdAYnnsX+HAlaxxnUMk4znfJRPxb 0Gt9BzcAxpsEtkdrC8FwCxCfZ5juRTKeB0rpYVZPdVMghOwAp40RvddHvhqtZcQ+ ahWLM9f0ECVAy/uOTHH8S2O7ZnVL4nzeQWC0Y3n6dAVLm/hUyCrrUP3AhRHkmPlK b4drjQqmKOCIHToMqUBvBUPjXfmataVYKYC6Ed/QTbsDxTaELq8= =y5EO -----END PGP SIGNATURE----- --------------0dkCB1hict2ujbBrgGILs0aI--