--- Additional Comments From giovannibajo at libero dot it 2005-05-10
15:48 ---
In my example, B is a (sort-of) derived class and A is a (sort-of) base class.
The C++ frontend should use a subobject at offset 0 to represent the base
class. When you downcast through dynamic_cast, you ar
--- Additional Comments From dberlin at gcc dot gnu dot org 2005-05-10
15:09 ---
And this would still work with the code i've written, because it's at offset 0
(which is why it's valid in C).
It would have worked before the fix, too.
It's only when you cast back *down* to the derived c
--- Additional Comments From joseph at codesourcery dot com 2005-05-10
14:59 ---
Subject: Re: [4.1 Regression] wrong code with
upcast in C++
On Tue, 10 May 2005, giovannibajo at libero dot it wrote:
> So what about this, in C:
Seems valid to me. "A pointer to a structure object, su
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-10
14:51 ---
(In reply to comment #4)
> void foo1(void* ptr)
> {
> ((struct A*)ptr)->a = 0;
> }
Because you just violated C aliasing. This is unlike C++ where upcasting is
okay.
--
http://gcc.gnu.org/bugzilla/sh
--- Additional Comments From giovannibajo at libero dot it 2005-05-10
13:17 ---
Ehm, bar should obviously be:
---
void bar(void)
{
struct B sb;
foo1(&sb);
foo1(&sb.sa);
foo2(&sb);
foo2(&sb.sa);
}
---
that is, I'm trying
--- Additional Comments From giovannibajo at libero dot it 2005-05-10
13:16 ---
So what about this, in C:
---
struct A
{
int a;
};
struct B
{
struct A sa;
int b;
};
void foo1(void* ptr)
{
((struct A*)ptr)->a = 0;
}
void foo2(void* ptr)
{
((struct
--- Additional Comments From dberlin at gcc dot gnu dot org 2005-05-09
13:58 ---
This is a call clobbering bug.
We don't pass the address of c to the call, we pass the address of some
substructure.
As a result, we don't think foo can touch c.b, when it can beause of the upcast.
Whee.
I'
--- Additional Comments From belyshev at depni dot sinp dot msu dot ru
2005-05-06 00:27 ---
Confirmed.
--
What|Removed |Added
Status|UNCONFIRMED
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-06
00:25 ---
Oh, I got the idea for this testcase after ssb asked about what the kernel was
doing was valid and his
example code but unlike that code, this is valid as C++ works slightly
different than C.
--
http:
--
What|Removed |Added
Target Milestone|--- |4.1.0
Version|4.0.0 |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21407
10 matches
Mail list logo