Problems with KSharedConfig
Christian Ehrlicher
Ch.Ehrlicher at gmx.de
Fri Feb 23 19:04:01 GMT 2007
Hi,
There is a report on kde-windows that kdelibs is currently not
compilable with msvc 7.1. After some investigation I found out why it
works with msvc 2005, but I don't know exactly how the compiler comes to
this conclusion.
The problem:
class KSharedConfig has no copy ctor, but is derived from KConfig with a
private copy ctor.
now there is a template KSharedPtr<T>::detach() which applies to
KSharedPtr<KSharedConfig>:
template <class T>
Q_INLINE_TEMPLATE void KSharedPtr<T>::detach()
{
if (d && d->ref>1) {
attach(new T(*d));
}
}
--> (d == KSharedConfig*, so I'm writing '&KSharedConfig')
template <KSharedConfig>
Q_INLINE_TEMPLATE void KSharedPtr<KSharedConfig>::detach()
{
if (&KSharedConfig && (&KSharedConfig)->ref>1) {
attach(new KSharedConfig(KSharedConfig));
}
}
which does not work because KConfig has a private copy ctor (at least
this is what msvc7.1 tells us).
But when I look into the preprocessed source from msvc2005, I see that
"attach(new T(*d));" is completly optimized away ... !?
I'm now looking what gcc 3.4.x is doing :)
So my question is - what's the intended behaviour here?
Thx,
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070223/db76417c/attachment.sig>
More information about the kde-core-devel
mailing list