Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1613910rdd; Thu, 11 Jan 2024 04:39:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPIOHFvA5EdX58IxTs93oA6fEN+M5+6HpZQ9fn1rXPRNfZ75IdNIDNojvFwtKkZtPQpekY X-Received: by 2002:a17:906:470d:b0:a23:6c6a:41a5 with SMTP id y13-20020a170906470d00b00a236c6a41a5mr561307ejq.45.1704976788064; Thu, 11 Jan 2024 04:39:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704976788; cv=none; d=google.com; s=arc-20160816; b=pF1QsWGscuGKmlRrYEj1RdVe9rsPYq5qM10iwPqG4pj9yanodEnq4OFyE+h+v5fgcW saT0fIZrEev7OkI1Ceh0biKXa4kkVui7GgMRhEwNci5o+P+AevOEPp29k0rDeiqf6NUm XMpkDfqacyPSFzgRFXZmaNVx9MaZXuj6d2svrLlZUR3khJ+KgN5+ICsWnIs6rmZx4KOe ThBvwzfwK+mm46VOgU+bt3vPOUp37llRukGPKM41XpiRt31DZAQG075Sc3Cz3LomfeUP kbjx6HsG39SI4JUuwGXi73QbR8UhnbYsJYzdUbnKrGhZcBJfPnYLoCbs8hgvFcEroEg0 1izw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=IlQjkQjyk1xjO1+lltG+XbCMeMA9HOeZJZxNsuhuvrc=; fh=wP+A8Y2tvX5cBWaPJ9qXL0SUVL9zd7UFJ7TJe+8TxRo=; b=oytZmZyzHFdMF7IaTHote5HtYD8nUL8kBtvR0AkiG3cDIaXyey3oFH0kRbgeTwHj7B FdYpapnfC1Zv8O/m1c3CqL8H4b1wfYXO4Bt7i42gGe3/MJXtDa61oL/GmhpNzBQ5Ig8x lldahJ9II4LhzHvo9WQfDYT0LQ+RwTYN3OVzSf4W6HxFiwkomS9OxOtJxxshaTK82Y14 zRTF529trWrfRtHt9lonVuN2DozWs1pH9UaFmwbnlI187cJDt/CV15lG2Upl1AK8ETuh h/VaHKIYdl4rhTzArnn6i1HSiG5yV5vA2db4ToREtORm8CLrKAsnRfhFD8hq2Xq9HqBv 1Zkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=jtIpjzOb; spf=pass (google.com: domain of linux-kernel+bounces-23595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=chrisdown.name Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y18-20020a170906471200b00a2695ca850dsi501971ejq.252.2024.01.11.04.39.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 04:39:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=jtIpjzOb; spf=pass (google.com: domain of linux-kernel+bounces-23595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=chrisdown.name Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CADCD1F24A46 for ; Thu, 11 Jan 2024 12:39:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6768715AE5; Thu, 11 Jan 2024 12:39:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="jtIpjzOb" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E45B315AC4 for ; Thu, 11 Jan 2024 12:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40e60e135a7so3866165e9.0 for ; Thu, 11 Jan 2024 04:39:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1704976775; x=1705581575; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=IlQjkQjyk1xjO1+lltG+XbCMeMA9HOeZJZxNsuhuvrc=; b=jtIpjzObMk+dR0zseb9hik62Xcc5IJyKKp1bk0WBv/Vj4K5iJwX7U6Vq99JP2BH+ql +Cyo9qYIdlSDocobgVu36UNEzivO7ped6SSO5AS7fr4/7tvVlE54NfZ4jOApC6YgtqDO mnlkHYzfTFrVHd+SZIFzPSYsHyhnZMkEK0wXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704976775; x=1705581575; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IlQjkQjyk1xjO1+lltG+XbCMeMA9HOeZJZxNsuhuvrc=; b=wwlfGaIHJm5WZYE6/iMZ8GkKvcHig6VK34uoPj5BZ0tb4t7nlUEqx1nlwotSlt+vNp lypPBs3jCTrpGAYIXVEPcLBzLBSY/9+H04gTYv1LfUT+mF8NDcNZty8O1VBrawJpIO0d 6Askl0GE+R4dIZHBb/6Nr+zZkJvQEmMMbl1RyIq8tcXroueA/3Qxk9CE/yjVQ9YLmKBd v7x60iDvU+i5GVX4rzIJreUTH+fvW4pH4D4RoWgFxiJDxU+kPhgtwaJLDgesVtvYMC2A K1l1e83YnWsvVskx/R6yEN8MTkPnysCj+wb2zpabWkvjBXGwdXM0cC6LN9Nf3QId9dUT y8FQ== X-Gm-Message-State: AOJu0Yx/7IVLTBnMuey8kxDlYOPdQ3FrPSbomgYR0JEPe28zzK4seObz 1NwgWmdysl84mlFr2KNLrNbJR/pu46L/o5zQRE3x13pvNMYq+g== X-Received: by 2002:a05:600c:538e:b0:40e:52e4:6938 with SMTP id hg14-20020a05600c538e00b0040e52e46938mr394197wmb.40.1704976775011; Thu, 11 Jan 2024 04:39:35 -0800 (PST) Received: from localhost ([2a01:4b00:8432:8600:5ee4:2aff:fe50:f48d]) by smtp.gmail.com with ESMTPSA id h17-20020a05600c499100b0040d6e07a147sm1698432wmp.23.2024.01.11.04.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 04:39:34 -0800 (PST) Date: Thu, 11 Jan 2024 12:39:33 +0000 From: Chris Down To: "H. Peter Anvin" Cc: Peter Zijlstra , David Howells , linux-kernel@vger.kernel.org, pinskia@gmail.com Subject: Re: [PATCH 00/45] C++: Convert the kernel to C++ Message-ID: References: <152261521484.30503.16131389653845029164.stgit@warthog.procyon.org.uk> <3465e0c6-f5b2-4c42-95eb-29361481f805@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <3465e0c6-f5b2-4c42-95eb-29361481f805@zytor.com> User-Agent: Mutt/2.2.12 (2023-09-09) H. Peter Anvin writes: >We already *do* use constructors and *especially* destructors for a >lot of objects, we just call them out. > >Note that modern C++ also has the ability to construct and destruct >objects in-place, so allocation and construction/destruction aren't >necessarily related. > >There is no reason you can't do static initialization where possible; >even constructors can be evaluated at compile time if they are >constexpr. Side note for the constructor and destructor discussion: should we be more widely marketing the __cleanup() infrastructure that Peter added a year or so ago? It likely helps a lot with at least some of these cases. In systemd we use __attribute__((cleanup)) pretty widely and my experience is that it's made the code a lot easier to both create and consume.