Bug 28706

Summary: [4.1 Regression] Compile failure with --combine and explicitly aligned structures
Product: gcc Reporter: David Woodhouse <dwmw2>
Component: cAssignee: Jakub Jelinek <jakub>
Status: RESOLVED FIXED    
Severity: normal CC: aldot, alexandre.nunes, aoliva, ddrake, dwmw2, gcc-bugs, pinskia
Priority: P2 Keywords: rejects-valid
Version: 4.1.1   
Target Milestone: 4.2.0   
URL: http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00447.html
Host: Target:
Build: Known to work: 4.0.0 4.2.0 4.3.1 4.4.0
Known to fail: 4.1.1 4.1.3 Last reconfirmed: 2006-08-14 13:42:11
Attachments: backported to gcc 4.1.2

Description David Woodhouse 2006-08-13 10:29:26 UTC
$ cat foo.c
struct rb_node
{
} __attribute__((aligned(sizeof(long))));

extern struct rb_node *rb_prev(struct rb_node *);
extern struct rb_node *rb_prev(struct rb_node *);
 $ gcc -c --combine foo.c foo.c
foo.c:6: error: conflicting types for ‘rb_prev’
foo.c:5: error: previous declaration of ‘rb_prev’ was here

gcc version 4.1.1 20060525 (Red Hat 4.1.1-1.pr27898)

Removing the explicit alignment fixes the problem.
Comment 1 Andrew Pinski 2006-08-13 15:19:20 UTC
This works in 3.4.0 and 4.0.0 so this is either a regression or a bug in redhat's compiler or a bug in the patch.
Comment 2 Andrew Pinski 2006-08-13 15:23:26 UTC
It is a regression.
Comment 3 Jakub Jelinek 2006-09-23 07:15:49 UTC
Subject: Bug 28706

Author: jakub
Date: Sat Sep 23 07:15:37 2006
New Revision: 117167

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117167
Log:
	PR c/28706
	PR c/28712
	* tree.c (merge_attributes, attribute_list_contained): If both
	TREE_VALUEs are TREE_LISTs, use simple_cst_list_equal instead of
	simple_cst_equal.
	* c-typeck.c (comptypes_internal): Don't consider aggregates
	in different TUs as compatible if there one set of attributes is
	not a subset of the other type's attributes.
	(composite_type): Try harder not to create a new aggregate type.

	* gcc.dg/pr28706.c: New test.
	* gcc.dg/pr28712.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr28706.c
    trunk/gcc/testsuite/gcc.dg/pr28712.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree.c

Comment 4 Daniel Drake 2007-02-21 19:50:53 UTC
Created attachment 13086 [details]
backported to gcc 4.1.2

Is there any chance of this fix appearing in a release before 4.3.0? I have backported it to 4.1.2 successfully. There was a trivial reject (indentation changes only) and also I had to add { } around the contents of the 2nd hunk in c-typeck.c

Let me know if I can help further.
Comment 5 Alexandre Oliva 2007-06-30 21:29:50 UTC
How about posting the backported-and-tested patch to gcc-patches, indicating on which platform you've tested it?
Comment 6 Alexandre Pereira Nunes 2008-01-15 17:40:56 UTC
This seems to work as of gcc 4.2.2 (vanilla), using the original commands to reproduce. Anyone denies/confirms this?
Comment 7 Alexandre Pereira Nunes 2008-01-15 17:55:15 UTC
(In reply to comment #6)
> This seems to work as of gcc 4.2.2 (vanilla), using the original commands to
> reproduce. Anyone denies/confirms this?
> 

... and please see bug 34800 .
Comment 8 Bernhard Reutner-Fischer 2008-06-19 14:10:09 UTC
works for me with 4.3.1 and current trunk
Comment 9 Joseph S. Myers 2008-07-04 15:48:24 UTC
Closing 4.1 branch.