const foo& - what is const - ReferenceType or ReferenceType::baseType ?

Milian Wolff mail at milianw.de
Wed Mar 2 16:55:29 UTC 2011


floris, 02.03.2011:
> On Wed, 2011-03-02 at 17:24 +0100, Milian Wolff wrote:
> > 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?
> > 
> > bye
> 
> they should both return const: a the reference of a reference type is
> ALWAYS const: you can't reseat a reference type.
> 
> int &foo =bar;
> foo=baz;//bar==baz now, foo still refers to bar
> 
> but the could should really check the base type because that's what the
> modifier belongs to.

I know how references work, I was talking about handling them in the DUChain 
;-)

> and for pointer types such a change would be devastating as const int* !
> = int * const

not talking about pointers here, they are handled separately in the DUChain.
-- 
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/2f96e8fd/attachment.sig>


More information about the KDevelop-devel mailing list