From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D99EDC8DC; Fri, 2 May 2025 01:24:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746149098; cv=none; b=pIhUlzOlqymN2cDSRSWa846jDEuhUoO++UPuyRpMOXaK0MOO6qp0TLSXjix6K6AXSiexXJS2XHOyOLzzXDhVsE0nzTFHrmIqFs85I/lx7e+LDjmyfs+WQbnvxbL3wavdGBaokFHc9TLBj/dY2Az6Dz0Eml4kWkb+iUxb2gHR/pU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746149098; c=relaxed/simple; bh=af7HpQ3v0hPoGlXDCTIrLUkdmd3jd6lgFoK/XGJ1cFA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WRAh9W6flrXwqXRhdsdK1MoJkfrYd5QT9g05KN49q0yeadbpw9PQ1v9lyR+xBV4ihWedgPXMyOQX0OHpHX9zPoN9z0XEDLrb91gG1XHzqrwqXgP0ONzqS/do/YyvfbYT+xRuhU4flGM5RNmu5Af14m+MUdaz/b3GXbg3WJyy1G0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YOA5IYgV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YOA5IYgV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78C14C4CEE3; Fri, 2 May 2025 01:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746149095; bh=af7HpQ3v0hPoGlXDCTIrLUkdmd3jd6lgFoK/XGJ1cFA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YOA5IYgVSCHIwwDgrz52mGuA7Y+xbenqnZVL7DZxOwLwD+hCrYPnhXNeRxyM3a/X/ KUz3NKnbR1e8/36/H/E632jPbzESpm2egxlzjL2ZABuLaKeEMQicsTp1G0BNOVCrVJ 8mKIr87E9PrppWV0447NPoJqZyZ9Px0ZkuPe2aHvE9NrimxbtQWrDwin2TLUNrfQLG gjR0HZ2YZGWwfzltOiID65eYnMWgD4YYYt5In9LzM1AISG/vjVmfyKcwIMazzE/i+Y 3bu42B0hn99buqPQhcVgnlqzOvO4tevzdBK6RdwnLcnQtwI3NFd6JJN4vEZRrfBAiy 0aWIG6+a63BYw== Date: Thu, 1 May 2025 18:24:49 -0700 From: Nathan Chancellor To: Linus Torvalds Cc: Andrew Morton , Masahiro Yamada , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, stable@vger.kernel.org, Linux Kernel Functional Testing , Marcus Seyfarth , Al Viro Subject: Re: [PATCH 2/2] include/linux/typecheck.h: Zero initialize dummy variables Message-ID: <20250502012449.GA1744689@ax162> References: <20250501-default-const-init-clang-v1-0-3d2c6c185dbb@kernel.org> <20250501-default-const-init-clang-v1-2-3d2c6c185dbb@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, May 01, 2025 at 04:28:25PM -0700, Linus Torvalds wrote: > On Thu, 1 May 2025 at 16:00, Nathan Chancellor wrote: > > > > +({ type __dummy = {}; \ > > + typeof(x) __dummy2 = {}; \ > > I'm actually surprised that this doesn't cause warnings in itself. > > The types in question are not necessarily compound types, and can be > simple types like 'int'. > > The fact that you can write > > int x = {}; > > without the compiler screaming bloody murder about that insanity blows > my mind, but it does seem to be valid C (*). I thought the same thing but I tend to trust people who are smarter than I am :) > How long has that been valid? Because this is certainly new to the > kernel, and sparse does complain about this initializer. As you noted, brace initialization for scalars appears to always be valid (at least in my testing) but as Al points out, empty braces for scalars is only supported in GCC 13+ and Clang 17+ (I think [1] was the clang commit), so that is not going to fly... > So honestly, this will just cause endless sparse warnings instead. I > think disabling this warning for now is likely the right thing to do. but '= {0}' appears to work: https://godbolt.org/z/x7eae5vex If using that instead upsets sparse still, then I can just abandon this change and update the other patch to disable -Wdefault-const-init-unsafe altogether (rather than just the field variant) but it seems like you were not entirely opposed to this even in spite of sparse not supporting it. If that does work, I will send a v2 tomorrow. [1]: https://github.com/llvm/llvm-project/commit/5d8aaad4452f60ba8902e921d9bed606713a8f26 Cheers, Nathan