All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Török Edwin" <edwintorok@gmail.com>
To: "Thomas Gleixner mingo@redhat.com" <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: gcc-4.3 considers unaligned accesses on X86 as undefined
Date: Tue, 25 Mar 2008 22:51:09 +0200	[thread overview]
Message-ID: <47E965BD.7010604@gmail.com> (raw)

Hello x86 architecture maintainers,

GCC-4.3 now considers that it is undefined behaviour to access memory
through an int*  that is not aligned to sizeof(int).
At -O3 it generates vectorized code that  _relies_  on the fact that
pointers are always aligned (unless you use packed attributes, etc.),
and the resulting code crashes if the pointer is unaligned.  (-O3 -msse
on 32-bit, and simply -O3 on 64-bit since -msse is default)
See this gcc bugreport: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35653
[I do not really agree with this sudden change, because unaligned
accesses have always been possible on x86, but the C99 standard does say
it is undefined behaviour ...]

I thought to inform you of this change in gcc's behaviour, because
include/asm-x86/unaligned.h is no longer safe in the above context,
especially that it is being used in a loop:
http://lxr.linux.no/linux/net/bluetooth/bnep/core.c#L153

P.S.: I only compile my kernels with -O2, so I don't know if it actually
crashes or not at -O3.

Best regards,
--Edwin


             reply	other threads:[~2008-03-25 20:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-25 20:51 Török Edwin [this message]
2008-03-25 20:56 ` gcc-4.3 considers unaligned accesses on X86 as undefined H. Peter Anvin
2008-03-25 21:11 ` Alan Cox
2008-03-26  5:30 ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47E965BD.7010604@gmail.com \
    --to=edwintorok@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.