public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54590] New: Incorrect multi-inheritence bases layout
@ 2012-09-15 14:08 wingfire at gmail dot com
2012-09-15 15:02 ` [Bug c++/54590] " schwab@linux-m68k.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: wingfire at gmail dot com @ 2012-09-15 14:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590
Bug #: 54590
Summary: Incorrect multi-inheritence bases layout
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: wingfire@gmail.com
the code:
#include <iostream>
struct A{ virtual void foo() {} };
struct B { void * data; };
struct X : public B, A { };
int main(){
X x;
if((void*)&x == (void*)(&x.data))
std::cout << "correct\n";
else
std::cout << "oops...\n";
return 0;
}
Expect:
print "correct"
Result:
print "oops..."
Notes:
if A::foo is not virtual, the result is correct.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54590] Incorrect multi-inheritence bases layout
2012-09-15 14:08 [Bug c++/54590] New: Incorrect multi-inheritence bases layout wingfire at gmail dot com
@ 2012-09-15 15:02 ` schwab@linux-m68k.org
2012-09-16 11:38 ` wingfire at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: schwab@linux-m68k.org @ 2012-09-15 15:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2012-09-15 15:02:12 UTC ---
The first word contains a pointer to the vtable for X.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54590] Incorrect multi-inheritence bases layout
2012-09-15 14:08 [Bug c++/54590] New: Incorrect multi-inheritence bases layout wingfire at gmail dot com
2012-09-15 15:02 ` [Bug c++/54590] " schwab@linux-m68k.org
@ 2012-09-16 11:38 ` wingfire at gmail dot com
2012-09-16 11:40 ` wingfire at gmail dot com
2012-09-16 12:37 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: wingfire at gmail dot com @ 2012-09-16 11:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590
--- Comment #2 from Sun, Chaoyang <wingfire at gmail dot com> 2012-09-16 11:38:24 UTC ---
(In reply to comment #1)
> The first word contains a pointer to the vtable for X.
If the first word is the vtable of X, the memory layout should be:
{
vptr of x;
data of B;
vptr of A;
}?
but the actual layout is:
{
vptr of X and A
data of B;
}
g++ swapped the memory ordered of A and B.
also,if I have
struct C{ virtual void foo() {} };
and X is defined:
struct X : public B, A,C { };
the actual layout will be:
{
vptr of X and A
data of B;
vptr of C;
}
Is it expected too? If so, it's too difficult to predicate the memory order of
each bases.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54590] Incorrect multi-inheritence bases layout
2012-09-15 14:08 [Bug c++/54590] New: Incorrect multi-inheritence bases layout wingfire at gmail dot com
2012-09-15 15:02 ` [Bug c++/54590] " schwab@linux-m68k.org
2012-09-16 11:38 ` wingfire at gmail dot com
@ 2012-09-16 11:40 ` wingfire at gmail dot com
2012-09-16 12:37 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: wingfire at gmail dot com @ 2012-09-16 11:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590
Sun, Chaoyang <wingfire at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
--- Comment #3 from Sun, Chaoyang <wingfire at gmail dot com> 2012-09-16 11:40:09 UTC ---
Back to unconfirmed. Maybe it's a "feature"?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/54590] Incorrect multi-inheritence bases layout
2012-09-15 14:08 [Bug c++/54590] New: Incorrect multi-inheritence bases layout wingfire at gmail dot com
` (2 preceding siblings ...)
2012-09-16 11:40 ` wingfire at gmail dot com
@ 2012-09-16 12:37 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-16 12:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |paolo.carlini at oracle dot
| |com
Resolution| |INVALID
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-16 12:37:22 UTC ---
When you say "should be", are you referring to the Itanium ABI? Because that is
the reference, and unless you have solid evidence that we are misimplementing
the ABI, this is not a Bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-16 12:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-15 14:08 [Bug c++/54590] New: Incorrect multi-inheritence bases layout wingfire at gmail dot com
2012-09-15 15:02 ` [Bug c++/54590] " schwab@linux-m68k.org
2012-09-16 11:38 ` wingfire at gmail dot com
2012-09-16 11:40 ` wingfire at gmail dot com
2012-09-16 12:37 ` paolo.carlini at oracle dot com
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).