From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS autolearn=no autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716239504; x=1716844304; darn=lists.altlinux.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date:sender:from :to:cc:subject:date:message-id:reply-to; bh=DW+GGTuvF6xzZm9BMXYtS6KwLnp4wxGiMKuQPHJHRlY=; b=gLmy7HI8phMdvhQ2/aeDbBGRTYg1m9qGGVqgvB0deRytN3jgaEUNcai0fkh3igAXuB Rcdoy+pic4n0TeCUtNeqAOHtc9unTbO20LOsePEG1uchCFrS9/LAvuPwyXiui/18uGiz QDj35InTSENrwxzPXqXfixBQVB5UyGuZPUEET5Ul1uSPy4fFog1FL2QxhFP6h/XWMESO A48mBe9zAYcVoyKm4zbMP89l+2ii7535gtHsjt8X85aeiq54MMyKXyVE3yg1oOPO2OkA L/qmeTIV9RjIjlv/CTMOMPbS3tOPJBN+j/LkxqEwlLufQUtVH8vIPQj+Z0bhLw9hoJyE csVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716239504; x=1716844304; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DW+GGTuvF6xzZm9BMXYtS6KwLnp4wxGiMKuQPHJHRlY=; b=Q7Nvm00E1DR07ZdwTLUqnm98e9mKk7ocJYv8qb3fa27A0usRvShFw80DPZOqhay+k9 23IvofqEOC8I2k1kC97JrphAM4pCPm16IBFD2i13ZeQK+g19OFo0Lw5KSS0r8pSEfODA Y2k+azoMvl0M6LmejTguNnoZbWvp9kHdBjtjb2yx2USGX5n9Asn+AtoFUXYyNiyWUPv6 Ap6VWzVsN0M2tfDul7Eai4khHtSgfRr452h9SR6UTrR4YR709rcA2GHm3FU54HXCP1Np C1uTNxfv6sh4lsfkgdBWvM/SEJkZBK3GFc/+/pQYMTBwQvPhC94zNbN1Fp0lgWrIb1Cw zrTQ== X-Gm-Message-State: AOJu0YwxUFiqROsJ1M9umnHKWpaan/HLXT4/daJaAzQcFv0PSEWg6Z62 4BXUYnx8+1YWG6ltk8UA79A0ESOpkXHZJOdJC6ht/tyl4x8/9YwKZerxoA== X-Google-Smtp-Source: AGHT+IGgnQSO+woZwpBZbnILVtXueGJ7hI6enHoz1Tdd/68hpNut8XY8/+NLdVRz867R1FdU5FOfjQ== X-Received: by 2002:a2e:5112:0:b0:2e6:d2bc:1d18 with SMTP id 38308e7fff4ca-2e6d2bc24e5mr120037261fa.22.1716239504015; Mon, 20 May 2024 14:11:44 -0700 (PDT) Sender: "Ivan A. Melnikov" Date: Tue, 21 May 2024 01:11:42 +0400 From: "Ivan A. Melnikov" To: ALT Linux Team development discussions Message-ID: References: <20240520203750.GA4067@imap.altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240520203750.GA4067@imap.altlinux.org> Subject: Re: [devel] =?utf-8?b?0YHRgtGA0LDQvdC90LDRjyDQv9GA0L7QsdC70LXQvNCw?= =?utf-8?b?INGBIGdjYz8=?= X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 May 2024 21:11:53 -0000 Archived-At: List-Archive: List-Post: On Mon, May 20, 2024 at 11:37:50PM +0300, Vladislav Zavjalov wrote: > Всем привет! > > Локализовал какую-то странную проблему в C коде, > не понимаю, это проблема с моим пониманием С или с компилятором. > > Код ниже: число печатается кусочками по два байта. > Это перестает работать при компиляции с -O2 или -O3. Это неопределённое поведение (UB), вызванное нарушением strict aliasing rules. Так делать не надо, но если очень хочется, (осторожно: учу плохому) добавьте `-fno-strict-aliasing` к ключам компилятора. А вообще про strict aliasing почитайте, полезное. -- wbr, iv m.