From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x934.google.com (mail-ua1-x934.google.com [IPv6:2607:f8b0:4864:20::934]) by sourceware.org (Postfix) with ESMTPS id 56E113858402 for ; Fri, 24 Sep 2021 09:38:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 56E113858402 Received: by mail-ua1-x934.google.com with SMTP id r8so6231531uap.0 for ; Fri, 24 Sep 2021 02:38:55 -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=aNy5e590Cu1DoOPvwN2Bws5VF2FqDuRVVVFm/iAN1TI=; b=IzCJnouf6CkkUDTL2OkyeUXCVRwjH841Q9Qh0/o7q0obQ3CNA0KCJZ6gXwP25qjfNE YSETWvDGex/T99116vuFxolGAqlPHAZgtCb6VAO9t/yrsUEKvN9lu6mFRjYcr+xP12fs bSvxGp7gm85/gOeBv9v59aB3VOodtreY2qLb84VvRaVZWBQhOMGMU20e3pOyznNb4gAF zIopvwQWLdmkO/sXbnsnoIZUjZxVoVllXa6jeTowoA7n42gpj0HqxO2E471HQR9db6P5 ELNig3uIia23pC1m4NO8ibFR+hJvVzQRmj/SAFJjvqzARSkoV2RpYbeIqSk+ww06bcRt dmcw== X-Gm-Message-State: AOAM530JUWT3QLqD6emKlU2XTu2KrMh047ZEzqlmR7T15czJGMux+O10 ndokYyjD0Q7OC9HSNJoAlWYQAKd80M9uhT8PQNw= X-Google-Smtp-Source: ABdhPJzgfS4rDD+wNAOR4EcVwYbM/1x2PTP+aKULZu0D5iG2Qlgvbk0AN3LTIROm9IriNXpvYTOxJQso6nByfbCJRDc= X-Received: by 2002:a05:6130:392:: with SMTP id az18mr8606313uab.71.1632476334954; Fri, 24 Sep 2021 02:38:54 -0700 (PDT) MIME-Version: 1.0 References: <88e1b98b-083b-4e2f-01ba-895dae16c58e@redhat.com> In-Reply-To: From: Andrew Pinski Date: Fri, 24 Sep 2021 02:38:42 -0700 Message-ID: Subject: Re: Can gcc.dg/torture/pr67828.c be an infinite loop? To: Aldy Hernandez Cc: GCC Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 24 Sep 2021 09:38:56 -0000 On Fri, Sep 24, 2021 at 2:35 AM Aldy Hernandez wrote: > > > > On 9/24/21 11:29 AM, Andrew Pinski wrote: > > On Fri, Sep 24, 2021 at 1:05 AM Aldy Hernandez via Gcc wrote: > >> > >> Hi folks. > >> > >> My upcoming threading improvements turn the test below into an infinite > >> runtime loop: > >> > >> int a, b; > >> short c; > >> > >> int > >> main () > >> { > >> int j, d = 1; > >> for (; c >= 0; c++) > >> { > >> BODY: > >> a = d; > >> d = 0; > >> if (b) > >> { > >> xprintf (0); > >> if (j) > >> xprintf (0); > >> } > >> } > >> xprintf (d); > >> exit (0); > >> } > >> > >> On the false edge out of if(b) we thread directly to BODY, eliding the > >> loop conditional, because we know that c>=0 because it could never overflow. > > > > Huh about c>=0 being always true? the expression, "c++" is really c= > > (short)(((int)c)+1). So it will definitely wrap over when c is > > SHRT_MAX. > > I see. > > Is this only for C++ or does it affect C as well? This is standard C code; promotion rules; that is if a type is less than int, it will be promoted to int if all of the values fit into int; otherwise it will be promoted to unsigned int. Thanks, Andrew Pinski > > Aldy >