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 9FF151FF61E for ; Thu, 26 Mar 2026 02:04:52 +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=1774490692; cv=none; b=tW1TExjnrPbQ2tVJRVKG5rZewc9ifOCpFSyYThxBSXhhxQfVwRD3rgmNd72FD2OKfDejGseibeIbZ9xrbgbd0t11rI8yfy2r6WxAZKsV7dD6qUq8KwCleLtUe8x0Ho7Du9FkCYO3HLkNsMID92qMuhavYIJDi3FlSIFSBsT8HO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774490692; c=relaxed/simple; bh=N/31S/ZH2A+KWQblOLKf36g92JALc+XnMCTW6/K69sw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Cw6JOk1kX03fqxC4tqyewC5X7qQ0pE+J42Ci5LyPv+XuOmxVpqfZYmDpnxhQ077XJMvhn9TlYMXRMppRb8Kh6ez3yrbm85dr822slJpxMzV+Rnu1M52G29275wcYUIysX503iY+ymJb+pBs+O2ie/x2KmD3cEXhNxJH5NVwL+kc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GnNiUqny; 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="GnNiUqny" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 891A5C4CEF7; Thu, 26 Mar 2026 02:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774490692; bh=N/31S/ZH2A+KWQblOLKf36g92JALc+XnMCTW6/K69sw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GnNiUqny2iCpFRdPz41by6927eJfhohMRzmeNxnhAjriEZ0d8OSWfRcLiRRsdsbML /MzBleKt6b9pwrlM6kMw4aiDEO3o1nuP2oFRXcw9L6rkLcrz7Rx+cgmyzffj8+f/Lv UZGi+J0mbC8CWSTItfGSY0P37jvAlahg/1XsdgfOxaL3J9ruvmP4N0VCvv1lSHID6e Wg1FcFwa080RArhNAdlsiz3obJOS3y1/ib0PtmFCFKIPOQPSO8JnZOo9PqVA/ire0f r9YDEvZNI70xNsCKoRVFYzlhplRLMbH3DSFs2RKvL7+v/KpBtqN8I1QWmmHiAgaIAo P51SxBsV4dEjA== Date: Wed, 25 Mar 2026 19:04:48 -0700 From: Nathan Chancellor To: hamjin Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib: typecheck: initialize const variable to avoid Clang warning Message-ID: <20260326020448.GA1294592@ax162> References: 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 Content-Disposition: inline In-Reply-To: On Sun, Mar 15, 2026 at 04:52:48PM +0800, hamjin wrote: > Building the kernel with newer Clang versions triggers > -Wdefault-const-init-var-unsafe in the typecheck() macro: > > error: default initialization of an object of type 'const unsigned long' > leaves the object uninitialized [-Wdefault-const-init-var-unsafe] > > The warning originates from the following declaration in typecheck(): > > typeof(x) __dummy2; > > When 'x' has a const-qualified type (e.g. 'const unsigned long'), > Clang warns that the variable is declared const but not initialized. > With -Werror enabled this causes the build to fail. > > Initialize the temporary variable to zero to silence the warning: > > typeof(x) __dummy2 = (typeof(x))0; > > This variable is only used for compile-time type checking and its > value is never read, so the initialization has no functional impact > on the generated code. > > Fixes: e0deaff47090 ("split the typecheck macros out of include/linux/kernel.h") > Signed-off-by: hamjin > --- > include/linux/typecheck.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/typecheck.h b/include/linux/typecheck.h > index 46b15e2aaefb..09f280da5b52 100644 > --- a/include/linux/typecheck.h > +++ b/include/linux/typecheck.h > @@ -8,7 +8,7 @@ > */ > #define typecheck(type,x) \ > ({ type __dummy; \ > - typeof(x) __dummy2; \ > + typeof(x) __dummy2 = (typeof(x))0; \ > (void)(&__dummy == &__dummy2); \ > 1; \ > }) > -- > 2.53.0 > As you can see from the build reports, this does not work. Are you missing commit d0afcfeb9e38 ("kbuild: Disable -Wdefault-const-init-unsafe") in your tree? Or does this appear in somewhere that uses its own KBUILD_CFLAGS, in which case a fix like 5ba35a6c13ff ("s390/boot: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS") b4780fe4ddf0 ("s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS") will be needed? I do not see any instances of this warning in Linus's tree unless I am missing some configuration in my build tests. Cheers, Nathan