public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18761] New: C++ ABI bug on OS X with enums
@ 2004-12-01 18:47 mmitchel at gcc dot gnu dot org
2004-12-01 18:56 ` [Bug c++/18761] C++ ABI bug on OS X with doubles pinskia at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-12-01 18:47 UTC (permalink / raw)
To: gcc-bugs
This program does not give the same alignment for A and B, which is very weird,
since the only difference is that B contains a declaration of a nested type.
The culprit here is the Darwin round_type_align code. I do not know if this bug
still occurs with GCC 4.0.
extern "C" int printf (const char*, ...);
union A {
double d;
};
union B {
enum E { e };
double d;
};
struct AlignA {
char c;
A a;
};
struct AlignB {
char c;
B b;
};
int main () {
printf ("Alignment of AlignA = %d\n", __alignof__ (AlignA));
printf ("Alignment of AlignB = %d\n", __alignof__ (AlignB));
}
--
Summary: C++ ABI bug on OS X with enums
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mmitchel at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc-apple-darwin7.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/18761] C++ ABI bug on OS X with doubles
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
@ 2004-12-01 18:56 ` pinskia at gcc dot gnu dot org
2004-12-01 18:59 ` mark at codesourcery dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-01 18:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-01 18:56 -------
The problem has nothing to do with enums at all but doubles, if the double is the second element in
the union it works. I do know that that would be correct for structs but I forgot about the rules for
unions. Darwin uses the same rule as AIX uses for alignment so it is also a problem there too if this is
a bug (someone will have to look it up).
In 4.0.0 we get:
Alignment of AlignA = 8
Alignment of AlignB = 4
which is what I had expected with my explaination about.
This gives the same output as the enum case (to show it has nothing to do with enums):
extern "C" int printf (const char*, ...);
union A {
double d;
};
union B {
int i;
double d;
};
struct AlignA {
char c;
A a;
};
struct AlignB {
char c;
B b;
};
int main () {
printf ("Alignment of AlignA = %d\n", __alignof__ (AlignA));
printf ("Alignment of AlignB = %d\n", __alignof__ (AlignB));
}
--
What |Removed |Added
----------------------------------------------------------------------------
GCC target triplet|powerpc-apple-darwin7.4.0 |ppc-darwin, ppc-aix
Keywords| |ABI, wrong-code
Summary|C++ ABI bug on OS X with |C++ ABI bug on OS X with
|enums |doubles
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/18761] C++ ABI bug on OS X with doubles
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
2004-12-01 18:56 ` [Bug c++/18761] C++ ABI bug on OS X with doubles pinskia at gcc dot gnu dot org
@ 2004-12-01 18:59 ` mark at codesourcery dot com
2004-12-01 19:08 ` [Bug c++/18761] C++ ABI bug on OS X with emebed types pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mark at codesourcery dot com @ 2004-12-01 18:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mark at codesourcery dot com 2004-12-01 18:59 -------
Subject: Re: C++ ABI bug on OS X with doubles
pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-01 18:56 -------
> The problem has nothing to do with enums at all but doubles, if the double is the second element in
> the union it works. I do know that that would be correct for structs but I forgot about the rules for
> unions. Darwin uses the same rule as AIX uses for alignment so it is also a problem there too if this is
> a bug (someone will have to look it up).
Andrew, you're being careless again. Look harder.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/18761] C++ ABI bug on OS X with emebed types
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
2004-12-01 18:56 ` [Bug c++/18761] C++ ABI bug on OS X with doubles pinskia at gcc dot gnu dot org
2004-12-01 18:59 ` mark at codesourcery dot com
@ 2004-12-01 19:08 ` pinskia at gcc dot gnu dot org
2004-12-01 19:10 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-01 19:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-01 19:08 -------
oh, yes now I see it.
Confirmed, the problem is really in rs6000_special_round_type_align where we only skip VAR_DECLs
but we should be skiping TYPE_DECLS also.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-12-01 19:08:28
date| |
Summary|C++ ABI bug on OS X with |C++ ABI bug on OS X with
|doubles |emebed types
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/18761] C++ ABI bug on OS X with emebed types
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-12-01 19:08 ` [Bug c++/18761] C++ ABI bug on OS X with emebed types pinskia at gcc dot gnu dot org
@ 2004-12-01 19:10 ` pinskia at gcc dot gnu dot org
2004-12-01 19:13 ` mark at codesourcery dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-01 19:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-01 19:10 -------
This patch should fix it:
Index: rs6000.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.757
diff -u -p -r1.757 rs6000.c
--- rs6000.c 27 Nov 2004 23:00:57 -0000 1.757
+++ rs6000.c 1 Dec 2004 19:09:39 -0000
@@ -3042,7 +3042,7 @@ rs6000_special_round_type_align (tree ty
/* Skip all the static variables only if ABI is greater than
1 or equal to 0. */
- while (field != NULL && TREE_CODE (field) == VAR_DECL)
+ while (field != NULL && TREE_CODE (field) != FIELD_DECL)
field = TREE_CHAIN (field);
if (field == NULL || field == type || DECL_MODE (field) != DFmode)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/18761] C++ ABI bug on OS X with emebed types
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-12-01 19:10 ` pinskia at gcc dot gnu dot org
@ 2004-12-01 19:13 ` mark at codesourcery dot com
2005-01-11 3:51 ` [Bug c++/18761] C++ ABI bug on OS X with embed types pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mark at codesourcery dot com @ 2004-12-01 19:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mark at codesourcery dot com 2004-12-01 19:13 -------
Subject: Re: C++ ABI bug on OS X with emebed types
pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-01 19:08 -------
> oh, yes now I see it.
> Confirmed, the problem is really in rs6000_special_round_type_align where we only skip VAR_DECLs
> but we should be skiping TYPE_DECLS also.
Right -- and CONST_DECLs!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/18761] C++ ABI bug on OS X with embed types
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-12-01 19:13 ` mark at codesourcery dot com
@ 2005-01-11 3:51 ` pinskia at gcc dot gnu dot org
2005-01-11 20:15 ` [Bug target/18761] " cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-11 3:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-11 03:51 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg00561.html>, sorry for not sending it
out sooner, I was reminded today (at least twice) to send the patch out.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pinskia at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/18761] C++ ABI bug on OS X with embed types
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
` (5 preceding siblings ...)
2005-01-11 3:51 ` [Bug c++/18761] C++ ABI bug on OS X with embed types pinskia at gcc dot gnu dot org
@ 2005-01-11 20:15 ` cvs-commit at gcc dot gnu dot org
2005-01-11 20:20 ` cvs-commit at gcc dot gnu dot org
2005-01-11 20:21 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-01-11 20:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-01-11 20:15 -------
Subject: Bug 18761
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: pinskia@gcc.gnu.org 2005-01-11 20:15:14
Modified files:
gcc : ChangeLog
gcc/config/rs6000: rs6000.c
Log message:
2005-01-11 Andrew Pinski <pinskia@physics.uc.edu>
PR target/18761
* config/rs6000/rs6000.c (rs6000_special_round_type_align):
Skip all DECLs except for FIELD_DECLs.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7093&r2=2.7094
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.c.diff?cvsroot=gcc&r1=1.773&r2=1.774
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/18761] C++ ABI bug on OS X with embed types
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
` (6 preceding siblings ...)
2005-01-11 20:15 ` [Bug target/18761] " cvs-commit at gcc dot gnu dot org
@ 2005-01-11 20:20 ` cvs-commit at gcc dot gnu dot org
2005-01-11 20:21 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-01-11 20:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-01-11 20:19 -------
Subject: Bug 18761
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: pinskia@gcc.gnu.org 2005-01-11 20:19:36
Modified files:
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/abi: align1.C
Log message:
2005-01-11 Andrew Pinski <pinskia@physics.uc.edu>
PR target/18761
* g++.dg/abi/align1.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4878&r2=1.4879
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/abi/align1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/18761] C++ ABI bug on OS X with embed types
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
` (7 preceding siblings ...)
2005-01-11 20:20 ` cvs-commit at gcc dot gnu dot org
@ 2005-01-11 20:21 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-11 20:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-11 20:20 -------
Fixed on the mainline. Also committed a testcase so we don't fail again and find other targets which
are wrong.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-01-11 20:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-01 18:47 [Bug c++/18761] New: C++ ABI bug on OS X with enums mmitchel at gcc dot gnu dot org
2004-12-01 18:56 ` [Bug c++/18761] C++ ABI bug on OS X with doubles pinskia at gcc dot gnu dot org
2004-12-01 18:59 ` mark at codesourcery dot com
2004-12-01 19:08 ` [Bug c++/18761] C++ ABI bug on OS X with emebed types pinskia at gcc dot gnu dot org
2004-12-01 19:10 ` pinskia at gcc dot gnu dot org
2004-12-01 19:13 ` mark at codesourcery dot com
2005-01-11 3:51 ` [Bug c++/18761] C++ ABI bug on OS X with embed types pinskia at gcc dot gnu dot org
2005-01-11 20:15 ` [Bug target/18761] " cvs-commit at gcc dot gnu dot org
2005-01-11 20:20 ` cvs-commit at gcc dot gnu dot org
2005-01-11 20:21 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).