From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by sourceware.org (Postfix) with ESMTPS id 986C13857C52 for ; Mon, 22 Feb 2021 09:29:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 986C13857C52 Received: by mail-yb1-xb30.google.com with SMTP id p186so12269278ybg.2 for ; Mon, 22 Feb 2021 01:29:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q8jxpn8U81BOSDGIdqWNhjKuVlBFdrywKBigHG1mI18=; b=sMWiYxNHCEH3GXEyClsCO19SS6e8f/JCngys7c7ZIjotDB8s0ILJ+mwjowFytBGWzL ojn2aA//53rUKPjLSLerMCtY2WuMBgjk5oiXTMNrdxdp7hmiFlepraouMcKyT+lU6DMd X5mrEG4O7S4m57pF6H3TDT2QFE8acDGFZ6DA0jcygfbPE8uKQOcUB/EWkx8UuHDRnBuU lS0flSW0CDturvUC6RhvlXX6CXrz8z/TIGPJhz0ELJ6gf/uKSq4gp4t951dKOu1rdDXf XUwlSVS2shMTMT9f6N53fesZ5aj33xbIhCXT0lE4/Nxh7c2x0cAbOiwKLBn8xmdlmStd fItA== X-Gm-Message-State: AOAM532ag498HIl0ZWIONAp4thsDNScZ+E0pU6yl+hpwpkROw2MuMtik HCAxnyEod17S/jy7o1sds/x8ZNmYmNSrwImGA8A= X-Google-Smtp-Source: ABdhPJzNvXewzVC+GXtRA9lzbkkp+LqVoUuimDuPMDblFY3bL1YLoG4H3b0p8nOxbHNsgupc7g8F3KAHAEvGoV5jUfk= X-Received: by 2002:a25:fa02:: with SMTP id b2mr29308317ybe.382.1613986174173; Mon, 22 Feb 2021 01:29:34 -0800 (PST) MIME-Version: 1.0 References: <80753cbc54ef69b4fc136f791666197fc8b1f8bb.camel@cyberfiber.eu> In-Reply-To: <80753cbc54ef69b4fc136f791666197fc8b1f8bb.camel@cyberfiber.eu> From: Andrew Pinski Date: Mon, 22 Feb 2021 01:29:23 -0800 Message-ID: Subject: Re: problems with memory allocation and the alignment check To: "Michael J. Baars" Cc: GCC Mailing List , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: Mon, 22 Feb 2021 09:29:35 -0000 On Mon, Feb 22, 2021 at 1:17 AM Michael J. Baars wrote: > > Hi, > > I just wrote this little program to demonstrate a possible flaw in both malloc and calloc. > > If I allocate a the simplest memory region from main(), one out of three optimization flags fail. > If I allocate the same region from a function, three out of three optimization flags fail. > > Does someone know if this really is a flaw, and if so, is it a gcc or a kernel flaw? There is no flaw. GCC (kernel, glibc) all assume unaligned accesses on x86 will not cause an exception. Thanks, Andrew > > Regards, > Mischa.