From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 638623857B8A for ; Tue, 2 Aug 2022 04:44:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 638623857B8A Received: by mail-lj1-x229.google.com with SMTP id m9so14388678ljp.9 for ; Mon, 01 Aug 2022 21:44:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc; bh=+2N8kj3KQA0siZK+zN6z1e2v/iVIulUb9fVgcPMjtnU=; b=mGJB48+t8FrMTau63GQvCwBMbAECQKGe0jX3wIJgHGANvisQ/iOZwr7gVJB1jDiI3U IxhOLe3g6XTITl54zoq0D77U/cr8+jMVCZVYZdYl/e9QVAn2xqCBcbcSrzrXfFjcjxHC WKtpIcpxOLQ+b7Kxw7MUn0dPWt3cwtDEWmK05e6JxDWoH+RiYcPXE9OkCAVAkpUHU8CV 033KkUCFqFMlYFGXpUgAG4VjK2wsM+E2eQtHf4WNENlZrlHATl/1YHj7fTi9uNOfqmV1 WbrQ1Qt2RhQsXa8wlNtM8qOWB5OzagEYHeCvyCkJgs4OyAwNkesT66ibWPClm2eMuyqS WFEw== X-Gm-Message-State: AJIora8io2DMB3TF7/iJBUaZLlbtG2JQ2dtzoL4JiJ0cQ1cqFJhkFTJd dk2pj8wQPlvljF9jO7HTKazh5j1fwAQgaOToSiTZFZvU X-Google-Smtp-Source: AGRyM1uzhMI72asdJIxi0L8DSAY5j83B0vHZyH5y12UUGlQ9D42/47aBH/AhSjTHfdH+AJhtBUHOptDihzdVEOArg60= X-Received: by 2002:a2e:6e0b:0:b0:25b:bf22:47a with SMTP id j11-20020a2e6e0b000000b0025bbf22047amr5967983ljc.524.1659415485605; Mon, 01 Aug 2022 21:44:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Haoxin Tu Date: Tue, 2 Aug 2022 12:44:09 +0800 Message-ID: Subject: Re: Possible wrong-code bug in GCC? To: GCC Mailing List X-Spam-Status: No, score=2.1 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: Tue, 02 Aug 2022 04:44:49 -0000 Oh, sorry for the noise, there is an integer overflow that may cause undefined behavior. Haoxin Tu =E4=BA=8E2022=E5=B9=B48=E6=9C=882=E6=97=A5= =E5=91=A8=E4=BA=8C 11:23=E5=86=99=E9=81=93=EF=BC=9A > Dear developers, > > May I seek your confirmation to check whether the following program > triggers a true wrong-code issue in GCC? The following piece of code look= s > too simple and I am not quite sure whether it's a bug or not. > > Here is the test program (s.c): > ``` > int a =3D 0, b =3D 0; > int main() { > for (; a <=3D 6; a++) { > c: > b++; > if (b) { > goto c; > } > } > return 0; > } > > ``` > $ gcc-trunk -O1 s.c ; ./a.out > (infinite loop) > $ gcc-trunk -O2 s.c ;./a.out > > Godbolt: https://godbolt.org/z/dx6efvv7x > > I guess the behavior of -O2 is normal as the if statement inside the > for-loop will be 0 after certain iterations. It's worth noting that almos= t > all versions of GCC behave the same in this case. Also, note that LLVM > behaves the same under the two optimization options; they all terminate t= he > execution in seconds. > > So, before I make any noise in the GCC bug repo, may I quickly check with > you and see whether the `s.c` is a potential wrong code bug in GCC, or > did I miss any important information here? I will file a new bug report > for this issue if it is a true bug. > > Thank you so much and looking forward to your reply! > > > Best regards, > Haoxin >