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 374FB303A0D for ; Fri, 6 Feb 2026 22:41:36 +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=1770417697; cv=none; b=HLnuFACuxP7J29aFsQgXf5Y5e17fiRhKam5l3iO6L7tMZRUW0lFcpA0nJ7jzDBvBiSsGFnSRikw+Wp+zVqYHxiezNWrvZvhEVI+/IzVa7MbODbhjB3FN43MtsFy2XsGgmzbQsRN/IRmPnQV7l8NodiQdJYwheOlhtbJQdvYYVBg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770417697; c=relaxed/simple; bh=e+zMKvF5NoVlL+jiBx1qmUKNZT6XAI9NP5I9cEadtHo=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=mhr+aJ5ZoA8v4qLzEnEvVWQ8Ak6O4MmnTiJngL1lSA3B+xCF0jSJs86ncdJ5ivjbrKg1OgolEZgTkFpNUAUhlP3bUWjxAhzeYnAze0CgNzImvSzdu01P3yhMcIwrQhsGw66tshjHMWRmOlasZ23mvpUOw5+MX68xElMJYuD6fSs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=Jdo0G/wA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Jdo0G/wA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63C98C116C6; Fri, 6 Feb 2026 22:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1770417696; bh=e+zMKvF5NoVlL+jiBx1qmUKNZT6XAI9NP5I9cEadtHo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Jdo0G/wAXIpNuOfTWR232cHZjJcdtHeGQdbHBXN3KG4wgtCispX//M0jFXLASC7xf 3tLYz97KsU54EBLryxLoIAwZ0OGbLrt09Bz1zMvhBSm5CNdEJeJCj6k1Vsc3jexbft A7t3ke552ilZUxhZMuW1/fyjlD+szkNOIeXiKkck= Date: Fri, 6 Feb 2026 14:41:35 -0800 From: Andrew Morton To: david.laight.linux@gmail.com Cc: Peter Anvin , Andy Shevchenko , Arnd Bergmann , Christoph Hellwig , "Jason A . Donenfeld" , Herve Codina , Linus Torvalds , linux-kernel@vger.kernel.org Subject: Re: [PATCH next] minmax.h: Use auto for variables in __minmax_array() Message-Id: <20260206144135.89b1edb4f25fed21b7a1ccc9@linux-foundation.org> In-Reply-To: <20260206222554.676171-1-david.laight.linux@gmail.com> References: <20260206222554.676171-1-david.laight.linux@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 6 Feb 2026 22:25:54 +0000 david.laight.linux@gmail.com wrote: > From: David Laight > > While 'auto __element = _array[--__len]' should remove 'const', > gcc prior to version 11 are buggy and retain it. With what effect? > However forcing an integer promotion by adding zero does work. > > Promoting signed/unsigned char and short to int doesn't matter here, > that happens as soon as the value is used. > > Type type of the result (for char/short arrays) changes, but the value s/Type type/Type/ ? > will always be promoted to int before it is used (for any purpose) so > it isn't even worth casting the type back - all that is likely to do > is make the compiler explicitly mask it to 8/16 bits before it is > immediately promoted back to int. I'm not understanding the motivation for this change. Is there some compilation issue to be addressed?