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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E1E673857004 for ; Sat, 17 Sep 2022 21:02:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E1E673857004 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663448562; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=CDeQOuHvxCntCr5KarEFQFJC49XMmFFbZuq9u0pHc3c=; b=bFPM1TpKKXvv3J56/ND6uz9ezgNQGALTjHfLbsZJaZ1jQnkwzoYhK5+EvDs8zbwdMc78ya o0/3yX7DozrV2fKDkFzq21libnUKJNmU+qh44h1fLBKd5US0m8h6L8kzQsy8yOLLEA6KCL Wef2qbbXGFhYDW3u46JlccNmKazaSr4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-3v6umSQnMQa4iwsokcGk2Q-1; Sat, 17 Sep 2022 17:02:41 -0400 X-MC-Unique: 3v6umSQnMQa4iwsokcGk2Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFC203C025C3; Sat, 17 Sep 2022 21:02:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D33E492B04; Sat, 17 Sep 2022 21:02:40 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28HL2adg132779 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 17 Sep 2022 23:02:37 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28HL2abH132756; Sat, 17 Sep 2022 23:02:36 +0200 Date: Sat, 17 Sep 2022 23:02:34 +0200 From: Jakub Jelinek To: Haoxin Tu Cc: GCC Mailing List Subject: Re: Question about why GCC produces the wrong-code bug Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Sat, Sep 17, 2022 at 11:18:56PM +0800, Haoxin Tu via Gcc wrote: > Dear developers, > > May I seek your help with some understanding of why GCC produces the > wrong-code bug? I understand that such a bug can only be reproduced in an > old GCC version, but I still want to know why GCC made mistake here. > > The bug-revealing code makes GCC-4.7.0 produce miscompiled code under the > -O3 option. > > $gcc-4.7.0 -O1 s.c -o s1; ./s1 > Aborted (core dumped) > $gcc-4.7.0 -O3 s.c -o s2; ./s2 >From what I can see, this has been introduced in r0-109841-g42373e0b05c26d047925387d71fa833540dad8f0 aka PR49094 fix and got fixed in r0-118982-gf2ea3c151c65c472024cf22b2e772819578d2011 aka PR54634 fix. But if you want to know more, you need to figure it out yourself, nobody is going to spend time on no longer supported 10 years old compiler. Jakub