From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 7F0773858001 for ; Fri, 24 Sep 2021 08:59:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7F0773858001 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-393-MBq8vUaPNK-1Mr3jvjkG5Q-1; Fri, 24 Sep 2021 04:59:37 -0400 X-MC-Unique: MBq8vUaPNK-1Mr3jvjkG5Q-1 Received: by mail-wr1-f71.google.com with SMTP id l9-20020adfc789000000b00160111fd4e8so7466486wrg.17 for ; Fri, 24 Sep 2021 01:59:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=+XbYzEfYm2WTYuQcLqu8acEqOC96Agig+T9CaBzHHq0=; b=dhOe6W8APg9LxH3ca1lCtTectN0fd+6btrXpk3pZ/4s++TDcpOl0238fU9uGiBr2rx hR0IXjqDW36bn1F9yK9xzCp0ILh8PKDy/tay3TC2dkCP9XBc0W4gF1eY+FQWe7phIoxq PhxfZvkSQXnj9BFOmXci+UU3lqNjiWS/rjwzUqOURScL+v8VH8lBo4J/Bpx0hYpVmanY 5MZ0Xulddz0JDVYiAOkhyjC1JrUbKkxYJpJ1lCCdn5d9oC2lMIku4mvqTAtSTDV9qRYf tJeFUIDZPgrFs/7/wUultg03vMNz3/9SFHICmXPCT986RW5moH0BIGCV2HFOtenDnFUE 75jQ== X-Gm-Message-State: AOAM5317wbt0KFdoCiFEd4PzjQxVmTsH1/HVi1fJuPXHknqO6xHVelRj Pg9mEFAeQ0y4d6WwbkBWzutLQEu0vDPlrAtUQBESOciuNLlmwQhGAaeIceAXxYfkCmpRDBoJ5gb e6Ef/peFIY7p6V2tpSR7uUUsydNokFYRgt2xmnCrTxlF5LFAAOIQ7vm8= X-Received: by 2002:a5d:5241:: with SMTP id k1mr9948265wrc.227.1632473976446; Fri, 24 Sep 2021 01:59:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+lOMIUYK675NRtlZOm2+BiSjQMsDOAC4I5HUctRN0OtBtQIbplFil4avueLuZAOF+lV2TTQ== X-Received: by 2002:a5d:5241:: with SMTP id k1mr9948236wrc.227.1632473976086; Fri, 24 Sep 2021 01:59:36 -0700 (PDT) Received: from abulafia.quesejoda.com ([139.47.33.227]) by smtp.gmail.com with ESMTPSA id u29sm7714859wru.34.2021.09.24.01.59.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Sep 2021 01:59:35 -0700 (PDT) Subject: Re: Can gcc.dg/torture/pr67828.c be an infinite loop? To: Richard Biener Cc: GCC Mailing List References: <88e1b98b-083b-4e2f-01ba-895dae16c58e@redhat.com> From: Aldy Hernandez Message-ID: <3d8e40f3-20e8-f265-85d8-d667aa65052a@redhat.com> Date: Fri, 24 Sep 2021 10:59:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 08:59:40 -0000 On 9/24/21 10:08 AM, Richard Biener wrote: > On Fri, Sep 24, 2021 at 10:04 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. >> >> Since B is globally initialized to 0, this has the effect of turning the >> test into an infinite loop. >> >> Is this correct, or did I miss something? > > Yes, 'c' will wrap to negative SHORT_MIN and terminate the loop via > the c>=0 test. Huh, so SHORT_MAX + 1 = SHORT_MIN? I thought that was an overflow, and therefore undefined. Aldy > > Mind c++ is really (short)(((int)c)++) and signed integer truncation > is implementation > defined. > > Richard. > >> Aldy >> >