This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/22447] gcc produces code that generate unaligned exceptions
- From: "falk at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jul 2005 22:27:25 -0000
- Subject: [Bug target/22447] gcc produces code that generate unaligned exceptions
- References: <20050712212227.22447.tsv@solvo.ru>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From falk at debian dot org 2005-07-12 22:27 -------
(In reply to comment #0)
> Instead of generating the code to store a byte using unaligned load/store
> instruction it uses aligned LDL/STL. The assembler code looks correct using -O0
> optimization flag and incorrect with -O1 and -O2. I tried to write smaler test
> case with the same pattern, but compiler compiles it correctly, so I am
> attaching the original preprocessed source. The function to look at:
> init_one_value.
typedef char *gptr;
typedef char my_bool;
[...]
static void init_one_value(const struct my_option *option, gptr *variable,
longlong value)
{
switch ((option->var_type & 127)) {
case 2:
*((my_bool*) variable)= (my_bool) value;
break;
[...]
At entry of the function, variable must be a null pointer, or point
to an object of type gptr = char*. Because of the dereferencing, gcc can
assume the former, and therefore *variable can be deduced to be 8-byte
aligned. (BTW, the other cases violate aliasing rules, since
they're not covered by the "lvalue of type char" exception.)
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22447