Bug 16407 - [3.3/3.4 Regression] Unaligned access to local variables
Summary: [3.3/3.4 Regression] Unaligned access to local variables
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 3.4.2
Assignee: Richard Sandiford
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-07-07 12:32 UTC by Richard Sandiford
Modified: 2013-03-11 17:07 UTC (History)
1 user (show)

See Also:
Host:
Target: mips64-elf
Build:
Known to work: 3.0.4
Known to fail: 3.2.3 3.3.4 3.4.1 4.0.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Sandiford 2004-07-07 12:32:57 UTC
The following testcase causes an unaligned access when compiled with
mips64-elf-gcc.

struct s { char c1, c2; };
void foo (struct s s)
{
  static struct s s1;
  s1 = s;
}
int main ()
{
  static struct s s2;
  foo (s2);
  exit (0);
}

The problem is that s1 and s2 are supposed to get word alignment,
but their asm declarations don't guarantee this.

The bug dates back to at least 3.2.3, but not 3.0.4, which didn't
take advantage of the extra alignment.
Comment 1 Richard Sandiford 2004-07-07 12:33:44 UTC
Testing a fix.
Comment 2 GCC Commits 2004-07-07 19:17:26 UTC
Subject: Bug 16407

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rsandifo@gcc.gnu.org	2004-07-07 19:17:06

Modified files:
	gcc            : ChangeLog 
	gcc/testsuite  : ChangeLog 
	gcc/config/mips: iris6.h mips-protos.h mips.c mips.h 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20040707-1.c 

Log message:
	PR target/16407
	* config/mips/mips-protos.h (mips_declare_common_object): Declare.
	* config/mips/mips.c (mips_declare_common_object): New function,
	mostly split out from...
	(mips_output_aligned_decl_common): ...here.
	* config/mips/mips.h (ASM_OUTPUT_LOCAL): Remove in favor of...
	(ASM_OUTPUT_ALIGNED_LOCAL): ...this new definition.
	* config/mips/iris6.h (ASM_OUTPUT_ALIGNED_LOCAL): Undefine this
	rather than ASM_OUTPUT_LOCAL.  Call mips_declare_common_object.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4341&r2=2.4342
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3944&r2=1.3945
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040707-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/iris6.h.diff?cvsroot=gcc&r1=1.77&r2=1.78
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips-protos.h.diff?cvsroot=gcc&r1=1.70&r2=1.71
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips.c.diff?cvsroot=gcc&r1=1.424&r2=1.425
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips.h.diff?cvsroot=gcc&r1=1.346&r2=1.347

Comment 3 GCC Commits 2004-07-07 19:21:31 UTC
Subject: Bug 16407

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	rsandifo@gcc.gnu.org	2004-07-07 19:21:16

Modified files:
	gcc            : ChangeLog 
	gcc/testsuite  : ChangeLog 
	gcc/config/mips: iris6.h mips-protos.h mips.c mips.h 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20040707-1.c 

Log message:
	PR target/16407
	* config/mips/mips-protos.h (mips_declare_common_object): Declare.
	* config/mips/mips.c (mips_declare_common_object): New function,
	mostly split out from...
	(mips_output_aligned_decl_common): ...here.
	* config/mips/mips.h (ASM_OUTPUT_LOCAL): Remove in favor of...
	(ASM_OUTPUT_ALIGNED_LOCAL): ...this new definition.
	* config/mips/iris6.h (ASM_OUTPUT_ALIGNED_LOCAL): Undefine this
	rather than ASM_OUTPUT_LOCAL.  Call mips_declare_common_object.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.539&r2=2.2326.2.540
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.221&r2=1.3389.2.222
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20040707-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/iris6.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.74.4.3&r2=1.74.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips-protos.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.59.4.3&r2=1.59.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.362.4.15&r2=1.362.4.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.310.4.6&r2=1.310.4.7

Comment 4 Richard Sandiford 2004-07-07 19:30:17 UTC
Fixed in mainline and 3.4.  Patch was posted here:

http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00647.html