From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-40132.protonmail.ch (mail-40132.protonmail.ch [185.70.40.132]) by sourceware.org (Postfix) with ESMTPS id C506F383A31A for ; Sat, 4 Jun 2022 11:55:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C506F383A31A Date: Sat, 04 Jun 2022 11:55:02 +0000 To: Yair Lenga From: Miika Cc: gcc@gcc.gnu.org Reply-To: Miika Subject: [RFC] Support for nonzero attribute Message-ID: In-Reply-To: References: Feedback-ID: 17471336:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jun 2022 11:55:12 -0000 On Saturday, June 4th, 2022 at 1:26 PM, Yair Lenga via Gcc wrote: > The specific non-zero constraint is a specific implementation of the rang= e > operator (with some exception see below). Wanted to suggest going for > more ambitious goal: add min and max attributes to (integer) types and > variables. This will address the specific case of non-zero, but has a lot > of potential to be built upon: can be used for compile time testing, run > time parameter checking, storage optimization (similar to packed), run ti= me > optimization (e.g. eliminating runtime tests), .... Also expected range > information can have a positive impact on code safety/validation. I like this idea a lot too. I'll definitely look into adding a "range" variable attribute after the work with function attributes is done. I'm not that familiar with GCC's optimizer but basic compiler warnings should be fairly easy to implement. Miika