[kde-solaris] Crash in kmail (kdepim-3.1.93)
James F. Hranicky
jfh at cise.ufl.edu
Mon Nov 24 13:51:26 CET 2003
On Mon, 2003-11-24 at 07:27, Eva Brucherseifer wrote:
> On Montag, 24. November 2003 12:53, James F. Hranicky wrote:
> > On Mon, 24 Nov 2003 02:22:34 -0400
> >
> > Stefan Teleman <steleman at nyc.rr.com> wrote:
> > > Should _never_ use C-style casts, but dynamic_cast<>(), and check for
> > > returning 0.
>
> You are casting "this" and this should never be 0 - strange thing.
Well, I am not, Trolltech is :-> Also, it isn't 0. It's a valid
address until the C-style cast, then the resulting value of c is an
invalid address.
> >
> > When I try changing the line to this:
> >
> > const QListViewItem* c = dynamic_cast<QListViewItem * const>(this);
>
>
> const QListViewItem* const c = dynamic_cast<QListViewItem * const>(this);
>
> or
>
> const QListViewItem* const c = this;
>
> should work. The pointer and the object are both const.
The first line gives this:
widgets/qlistview.cpp:3815: error: cannot dynamic_cast `this' (of
type `const
class QListViewItem* const') to type `class QListViewItem* const' (
conversion casts away constness)
and both lines give this:
widgets/qlistview.cpp:3818: error: assignment of read-only variable
`c'
> Still casting away the const shouldn't give any seg faults. I'd expect the
> problem to be something else. This is only intuition though, since I don't
> know the code.
Yes, more than likely. Perhaps I should try compiling with gcc's bounds
checking? Has anyone tried this to see how many errors are caught in
QT/KDE?
Jim
More information about the kde-solaris
mailing list