From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by sourceware.org (Postfix) with ESMTPS id F107238277B2 for ; Sat, 4 Jun 2022 21:29:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F107238277B2 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-30c2f288f13so112113787b3.7 for ; Sat, 04 Jun 2022 14:29:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4tAG0FaSh1kQ7KkXaQzNYi0HWPZUTWvEj1rolJPaC3g=; b=p7AKYTdBLksXSDIT4zYqSr96o/zMb2998NGl7eAXhJ7KVsZDa6yK9LiQlHCXcblxz2 L1EhJWXyT/Kr4xv5kD65EsDA8HJB7cha657km5BxI3tgEZvWVTe2arJUwtFCnxHE/Y7W R1Osb3wAGlf8wvG0EJGg+tAKb9Xb+LREgINob2pu4tsraF7B2UhntJD4W/AHwaPfH+AX b4owJaOWtr0PB6C6xJc3vNf092raWMaGJUq7hteIZkXNS3Am3PYd67s1W9QivGQmhHRo YFKhJTiedZ9EQB/D23bnEnjm37r3jvKOwF12pTaR8hdm5yFT/6CiSMR1lFgX/kuk4KsG GKQw== X-Gm-Message-State: AOAM533zPTbwKGMDmt1Y0D8t1wkeOzCRJeXQclEsONkgvKj0hTMcEnKz /CGQ7w7TPE3wGJSXtqVu2I07XSE7/XKJC2br458= X-Google-Smtp-Source: ABdhPJwx5O0skKRqNvrne5HQKWNqfymijG1qPXJwutDPSo6wH/zXkkG9fYhArc1hsWuBtbzf26Ie+JTiEEGfHkBX8Ck= X-Received: by 2002:a81:75c6:0:b0:30c:5ed2:8a00 with SMTP id q189-20020a8175c6000000b0030c5ed28a00mr17579883ywc.186.1654378188331; Sat, 04 Jun 2022 14:29:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yair Lenga Date: Sat, 4 Jun 2022 17:29:36 -0400 Message-ID: Subject: Re: [RFC] Support for nonzero attribute To: Miika Cc: gcc@gcc.gnu.org X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 21:29:50 -0000 Static checks will be a good starting point! On Sat, Jun 4, 2022 at 7:55 AM Miika wrote: > On Saturday, June 4th, 2022 at 1:26 PM, Yair Lenga via Gcc < > gcc@gcc.gnu.org> wrote: > > The specific non-zero constraint is a specific implementation of the > range > > 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 > time > > 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 >