const foo& - what is const - ReferenceType or ReferenceType::baseType?
Milian Wolff
mail at milianw.de
Wed Mar 2 16:55:43 UTC 2011
David Nolden, 02.03.2011:
> 2011/3/2 Milian Wolff <mail at milianw.de>:
> > Hey David,
> >
> > just spotted an issue in the shortenedTypeIdentifier, it checks whether
> > the identifier is a const ref using this code:
> >
> > bool isReference = false;
> > bool isConstReference = false;
> > if(type.cast<ReferenceType>()) {
> > isReference = true;
> > isConstReference = type.cast<ReferenceType>()->modifiers() &
> > AbstractType::ConstModifier;
> > type = type.cast<ReferenceType>()->baseType();
> > }
> >
> > But the reality shows: Not the ReferenceType is const, but it's baseType!
> > So I'll fix it here, but I wonder whether this could not be hit
> > elsewhere? Should the ReferenceType maybe return the same modifiers as
> > it's baseType to prevent such problems?
>
> This has changed with time. The way it is now, it is more logical,
> because it is the same as with pointers. The difference is that a
> reference cannot be constant at all in our sense, because references
> are always constant, they cannot be changed to point to something
> different after they were initialized. Well, maybe it would be good to
> return the modifiers of the baseType in ReferenceType::modifiers,
> because a ReferenceType cannot have modifiers at all. However this
> would be slightly ugly, because it wouldn't be consistent with
> "setModifiers", so we should probably keep everything as it is. Also
> there might be other languages where reference-types _can_ take
> const-modifiers.
>
> Most places should handle this properly though. Would be nice if you
> could add a unit-test to make sure this fix stays.
will do. thanks for the clarification.
bye
--
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110302/948d5bb6/attachment-0001.sig>
More information about the KDevelop-devel
mailing list