From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by sourceware.org (Postfix) with ESMTPS id AEDA83858028 for ; Tue, 2 Aug 2022 03:24:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AEDA83858028 Received: by mail-lj1-x235.google.com with SMTP id z20so7169632ljq.3 for ; Mon, 01 Aug 2022 20:24:30 -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:mime-version:x-gm-message-state :from:to:cc; bh=8rL/VaPHnM+JvfX7twa9wN+CHYL1umdKPHJmMz1Pi6o=; b=oC+xmwakvWHiGXqo88qQpTCNrR7PAIvljsd6hVFAQ6EzWrg393Q7VKn542wkBo/doB A/tg8DZsLGWBMiRaPip0ZSECcjxKGK3hBtwqqgtk0MxVnuN2pzzrGExdfJV2nI+76aRk +NrsLH9lan2B0xXhi41x4AryFaNlPgRRO7Z97mHoGFsV/ucs9piVFRkFnr1uK/CGp3Ym 2YhfSogED/jaP8TIgZazPfxsiifWoccTULiLFELZPsakJpzUM0gJ+DmaOy21kloDDx7+ L5GTTi2iEpS3lNB28Po4GbGEW4npWV6pDIar9aJinkV4CcG0Sz34y3i8W6mQRqqIXv+a zM4A== X-Gm-Message-State: ACgBeo0w3NYbBXHnwsNsNm8LDXn800vQ4jQC0iWETGgtUeSOamBUpZdT v/RpwUiAW0CgGL54POmjKoJMB3D3fqiZioFJ0yfjQ30uq1w= X-Google-Smtp-Source: AA6agR6vUHAkWKkyVQNgpPOq1f+UnzvCEeVqddrxo5dUMKfWnFyae+SFK1FXRYHqwFcgNnGLD22Xo+8lRUIt3K+OuiI= X-Received: by 2002:a2e:b914:0:b0:25e:4206:27c1 with SMTP id b20-20020a2eb914000000b0025e420627c1mr5631470ljb.156.1659410668119; Mon, 01 Aug 2022 20:24:28 -0700 (PDT) MIME-Version: 1.0 From: Haoxin Tu Date: Tue, 2 Aug 2022 11:23:52 +0800 Message-ID: Subject: Possible wrong-code bug in GCC? To: GCC Mailing List X-Spam-Status: No, score=-0.1 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 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: Tue, 02 Aug 2022 03:24:33 -0000 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 looks too simple and I am not quite sure whether it's a bug or not. Here is the test program (s.c): ``` int a = 0, b = 0; int main() { for (; a <= 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 almost 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 the 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