Bug 32617 - explow.c references DECL_ALIGN of a FUNCTION_DECL
Summary: explow.c references DECL_ALIGN of a FUNCTION_DECL
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Geoff Keating
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-03 20:55 UTC by Geoff Keating
Modified: 2007-07-21 08:35 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-07-03 21:53:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Geoff Keating 2007-07-03 20:55:48 UTC
In explow.c, there's this code:

    if (GET_CODE (x) == SYMBOL_REF)
      {
        align = BITS_PER_UNIT;
        if (SYMBOL_REF_DECL (x) && DECL_P (SYMBOL_REF_DECL (x)))
          align = DECL_ALIGN (SYMBOL_REF_DECL (x));
      }

If SYMBOL_REF_DECL(x) is a FUNCTION_DECL, DECL_ALIGN() does not have valid data, so this code will cause the alignment of a function's MEM to be set to random data.
Comment 1 Richard Biener 2007-07-03 21:05:56 UTC
Confirmed.
Comment 2 Geoff Keating 2007-07-10 23:09:06 UTC
Subject: Bug 32617

Author: geoffk
Date: Tue Jul 10 23:08:52 2007
New Revision: 126529

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126529
Log:
2007-07-09  Geoffrey Keating  <geoffk@apple.com>

	PR 32617
	* c-common.c (c_alignof_expr): Look at DECL_ALIGN of
	FUNCTION_DECLs.
	(handle_aligned_attribute): Allow use on FUNCTION_DECLs.
	* varasm.c (assemble_start_function): Honor DECL_ALIGN
	for FUNCTION_DECLs.  Don't use align_functions_log if
	DECL_USER_ALIGN.
	* print-tree.c (print_node): Print DECL_ALIGN and DECL_USER_ALIGN
	even for FUNCTION_DECLs.
	* c-decl.c (merge_decls): Propagate DECL_ALIGN even for
	FUNCTION_DECLs.
	* tree.h (DECL_ALIGN): Update for new location of 'align'.
	(DECL_FUNCTION_CODE): Update for new location and name of
	'function_code'.
	(DECL_OFFSET_ALIGN): Update for new location of 'off_align'.
	(struct tree_decl_common): Move 'align' and 'off_align' out
	of union, ensure they're still on a 32-bit boundary.  Remove
	other fields in union 'u1'.
	(struct tree_function_decl): Add field 'function_code' replacing
	'u1.f' in tree_decl_common.
	* tree.c (build_decl_stat): Set initial value of DECL_ALIGN.
	* doc/extend.texi (Function Attributes): Add 'aligned' attribute.
	(Variable Attributes): Cross-reference 'aligned' attribute
	to Function Attributes.
	* flags.h (force_align_functions_log): Delete.
	* toplev.c (force_align_functions_log): Delete.

Index: gcc/testsuite/ChangeLog
2007-07-09  Geoffrey Keating  <geoffk@apple.com>

	PR 32617
	* gcc.c-torture/execute/align-3.c: New.

Index: gcc/java/ChangeLog
2007-07-09  Geoffrey Keating  <geoffk@apple.com>

	PR 32617
	* lang.c (java_init): Remove setting of force_align_functions_log.
	* class.c (add_method_1): Set DECL_ALIGN of non-static method
	to cope with ptrmemfunc_vbit_in_pfn.

Index: gcc/cp/ChangeLog
2007-07-09  Geoffrey Keating  <geoffk@apple.com>

	PR 32617
	* decl.c (cxx_init_decl_processing): Don't set
	force_align_functions_log.
	(grokfndecl): Honour ptrmemfunc_vbit_in_pfn.
	* typeck.c (cxx_alignof_expr): When alignof is used on a plain
	FUNCTION_DECL, return its alignment.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/align-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-decl.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/doc/extend.texi
    trunk/gcc/flags.h
    trunk/gcc/java/ChangeLog
    trunk/gcc/java/class.c
    trunk/gcc/java/lang.c
    trunk/gcc/print-tree.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/toplev.c
    trunk/gcc/tree.c
    trunk/gcc/tree.h
    trunk/gcc/varasm.c

Comment 3 Andrew Pinski 2007-07-21 08:35:51 UTC
Fixed.