On Mon, 2021-02-22 at 10:50 +0100, Gabriel Ravier via Gcc wrote:
> On 2/22/21 10:37 AM, Michael J. Baars wrote:
> > On Mon, 2021-02-22 at 01:29 -0800, Andrew Pinski wrote:
> > > On Mon, Feb 22, 2021 at 1:17 AM Michael J. Baars
> > > <mjbaars1977....@cyberfiber.eu> 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.
> > Is this just an assumption or more like a fact? I agree with you that byte 
> > aligned is more or less the same as unaligned.
> IIRC it's a fact, unless you change EFLAGS to enable the unaligned 
> access exception flag, which is forbidden by the ABI.

I see :)

> > > Thanks,
> > > Andrew
> > > 
> > > > Regards,
> > > > Mischa.

Reply via email to