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 3777C3858C3A for ; Wed, 22 Dec 2021 10:34:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3777C3858C3A Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-448-J6eK4163PYCs5yy6F-XX7Q-1; Wed, 22 Dec 2021 05:34:55 -0500 X-MC-Unique: J6eK4163PYCs5yy6F-XX7Q-1 Received: by mail-qv1-f69.google.com with SMTP id fq14-20020a056214258e00b004112371dccaso1802920qvb.0 for ; Wed, 22 Dec 2021 02:34:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=YFxme2v9xHg8eu6z2c8qLknxJgYKos+FY66epCONewc=; b=iX6uKwJoUmCtVtz7ySnwcJplDxYolRDlIT89bWBHVfklJ/PnlpBD4opwDMPnxsCPUi whTUcQ6a4NWd5D+sHxJy7J3BrzKOb4jobWuAd1tE5ePaNOKvOmfvLiVVYmoq5MTBV+RV rbWXxK9ZRfehG/J4C8g0HugGb8lphAOLXerScsWDXrsmxYBN8QxC49RlEU85t/tFODdy /6mK//KO5NPTxpFLiJuuTfHr6qcouyJsQufDaRdKuOCqsNP53vx6ShZVnB6aqmDbU0VP wdWc6z+krbZGHQdhr7U441KBhqbGISW/+bYGYv/FF2J4SM8R1O1QamlyfhYgRtLenWHr iC3w== X-Gm-Message-State: AOAM533KZRNf9iIGAdRFYjZxgEmP6/byW5igvDYyl3/xpG8JjhTLOHpi 9cJdGmKuhMO9npq70+Ydkyrgu27DCDf5XfKZ7NdhkcSl28By9pU7rSC6SmVm9kWM4At1VJp2SOe p4hMhwLTgLGXMaA== X-Received: by 2002:ad4:5e8c:: with SMTP id jl12mr1800907qvb.83.1640169295550; Wed, 22 Dec 2021 02:34:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJymQlnDiavrfb1bHqcYsPip38y/47D7NkeKT9m7Cuc3rAf0DQBKyxCcY++5nJew3+qHmhHkTA== X-Received: by 2002:ad4:5e8c:: with SMTP id jl12mr1800899qvb.83.1640169295341; Wed, 22 Dec 2021 02:34:55 -0800 (PST) Received: from [192.168.0.129] ([81.0.47.68]) by smtp.gmail.com with ESMTPSA id f16sm1426340qkk.16.2021.12.22.02.34.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Dec 2021 02:34:54 -0800 (PST) Message-ID: Date: Wed, 22 Dec 2021 11:34:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: broken code only when optimized "-O2" To: Florian Weimer , Adrian Moreno via Gcc-help Cc: David Brown , Stefan Ring References: <9b28799e-71f8-2ef9-1cc9-01345993cc11@redhat.com> <877dbx7x47.fsf@oldenburg.str.redhat.com> From: Adrian Moreno In-Reply-To: <877dbx7x47.fsf@oldenburg.str.redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 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_H3, RCVD_IN_MSPIKE_WL, 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-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2021 10:34:58 -0000 On 12/22/21 11:27, Florian Weimer wrote: > * Adrian Moreno via Gcc-help: > >> So here I do not know what the compiler would think about "pos" if it >> happens to point to some invalid stack address. > > In such cases, the compiler typically assumes that the code in question > is never executed. This means that the comparison does not need to be > performed, among other things. > So it wouldn't cause undefined behavior? Thanks. -- Adrián Moreno