how to backport without breaking ABI?
floris
flo.ruijt at gmail.com
Sun Feb 13 00:06:00 UTC 2011
On Sat, 2011-02-12 at 21:12 +0100, Andreas Pakulat wrote:
> On 12.02.11 20:49:40, Milian Wolff wrote:
> > http://commits.kde.org/kdevplatform/288c92e122776b6310b3862d02372e465fd16837
> >
> > the commit message says it all, I just forgot the CCMAIL...
> >
> > Input?
>
> You can't, period. Thats why Qt uses the dptr stuff (including
> dptr-subclasses) for its public API.
>
> Andreas
>
> --
> Someone is speaking well of you.
>
isn't there a reasonable chance that KSharedPtr has the same layout as a
simple pointer? I mean the only member of KSharedPtr is the raw pointer
(reference counting happens apparently inside the pointed object)
therefore the change won't break this pointer, the only problem i see
would be when this happens:
struct foo {
int data;
bar* inst;
int more_data
};
struct foo {
int data;
KSharedPtr<bar> inst;
int more_data;
};
i think the padding after inst is allowed to change, but i'm quite sure
that dereferencing the second int as if it were the first should work
the more_data could be moved, i guess, but it doesn't happen here.
to test my hypothesis i made a little test:
#include <cassert>
int main(){
struct AA{
int* ptr;
};
struct BB{
int m1;
int* m2;
int m3;
}b;
struct CC{
int m1;
AA m2;
int m3;
}c;
assert(sizeof(BB)==sizeof(CC));
assert((long long)&b.m1-(long long)&b ==(long long)&c.m1-(long long)&c
);
assert((long long)&b.m2-(long long)&b ==(long long)&c.m2.ptr - (long
long)&c );
assert((long long)&b.m3-(long long)&b ==(long long)&c.m3-(long long)&c
);
}
of course older kdevelops which treat that member as a simple pointer
can still store a raw pointer which gets deleted prematurely, but
there's really nothing you can do about that.
Floris
More information about the KDevelop-devel
mailing list