From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 949343858D1E for ; Tue, 24 Jan 2023 14:26:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 949343858D1E 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-ej1-x636.google.com with SMTP id v6so39477815ejg.6 for ; Tue, 24 Jan 2023 06:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eQtDqWTF85FJbDTfyvDN9LyHkE51UGOJF1hLZAxl3i8=; b=RGLkledrbmsJzZDAmj9aDWwcEaHAKC4CqzR+ZsnwRqb1unVxw0TCmehfQg5pziqDZZ eYhph3EgSGbsEs7yYFtHC7CMHQClezYeHBXBlPP/0AZoCkRvYDwsQF6Z4QLXp8ZIVm1H 5rBpopbsQEM/x4OvASMsDVkN0bW2ZBhD3nslRABSRM/GV724Y3mS1Zhqf5Rd4l+ddFiB tO9bzC7XwBHaNCwk8EFpd/H0BNyCmRVtMX5D6HK3Ib33Kgkj0i7rpw2irirH8lbQIkRD Kz/ChHtv+w5SZoocDd49DoQembORQHuBejtkWYUBdXHJblaYemDfD+48YSaIuy0rtAaD Wdyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eQtDqWTF85FJbDTfyvDN9LyHkE51UGOJF1hLZAxl3i8=; b=T5ZwyeB7sjlTpb0Uh6tY3bK1wCsIP99QRQ5XIMNSKBDv97mvcKfmYb2g3D/tynNVwV gzLU8zNMXKRvBcAUASK8F5ZS35fjRclmsH16/rFeAx44DVz4Vid0h8XUsypxki0Ma69o 2MZxdyTDtORDL0hKvnPt9Ba0lbPLzaDLWjadth8MDC01ZWZJuak9wxF2mg3kfox8QaJG INhr6cnKJe5hGgb2D9tfPAL9Qt7pEtetogpk1w/Ca2jEGsReXThoOceJOI0wv2zjzA5T 5l6fScmjzNTQJ9362tpQ6e3wkpSpNLdP8uFuoO2rzpGC3s0SJS7tfdlx7k42xVz/oB6N /RZw== X-Gm-Message-State: AFqh2kroAmS6eGIkLsj6gotrmQ4i4xMBImdLL0PgnNJJjD1cAMThEuDn mElAnIz/FURlvao7n6zxaa+UT7SRHaeokWPlb3A= X-Google-Smtp-Source: AMrXdXtvDJ38rmtiU1nSLgNkOW9P/KjqXleuI7ATzldAXLOJCRxcWriKBqW0Skx6RqDeC7gafHxuBTpuYt8KBc/hJxw= X-Received: by 2002:a17:906:b208:b0:86e:2c11:9bc9 with SMTP id p8-20020a170906b20800b0086e2c119bc9mr3714240ejz.129.1674570396271; Tue, 24 Jan 2023 06:26:36 -0800 (PST) MIME-Version: 1.0 References: <4366aeb5-7fdb-6fa4-b0f5-ebe74c1d4fb2@jguk.org> <68c69b5a-e6e7-7021-5f98-37ba8f3c49eb@jguk.org> <0e2290f2-6d87-b4cb-1853-be54c7a45d08@jguk.org> In-Reply-To: <0e2290f2-6d87-b4cb-1853-be54c7a45d08@jguk.org> From: Jonathan Wakely Date: Tue, 24 Jan 2023 14:26:24 +0000 Message-ID: Subject: Re: Avoiding stack buffer clear being optimised out To: Jonny Grant Cc: gcc-help Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: On Tue, 24 Jan 2023 at 13:52, Jonny Grant wrote: > > Probably other functions be "compiled out" like memset() is, would memcpy() be compiled out? The compiler can do anything which does not change the observable side effects of a valid program. https://en.cppreference.com/w/cpp/language/as_if So yes, the compiler can omit a memcpy that doesn't do anything. Or any other function call that doesn't do anything.