[haiku-commits] Re: [haiku-commits] Re: r38086 -=D=A haiku/trunk/src/servers/app/drawing/Painter

  • From: pulkomandy <pulkomandy@xxxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 13 Aug 2010 15:46:02 +0200

On Fri, Aug 13, 2010 at 09:38:41AM -0400, Rene Gollent wrote:
> On Fri, Aug 13, 2010 at 9:18 AM,  <pulkomandy@xxxxxxxxxxxxxxxxx> wrote:
> > CID 1556 : wrong cast type.
> >
> > ?? ?? ?? ?? ?? ?? ?? ??const BGradientLinear* linearGradient
> > - ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? = dynamic_cast<const 
> > BGradientLinear*>(&gradient);
> > + ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? = static_cast<const 
> > BGradientLinear*>(&gradient);
> > ?? ?? ?? ?? ?? ?? ?? ??if (linearGradient->Start().x == 
> > linearGradient->End().x
> 
> dynamic_cast was correct there, this is a false positive.

Why so ? From my understanding, one should use dynamic_cast only when
not sure about the type of the object, as dynamic_cast performs a
runtime check and can return null in case of error. Here :
 * We are sure about the type, it's checked in the line just before
 * The fact that dynamic_cast may return null isn't checked against

Could you enlighten me then ?

-- 
Adrien.

Other related posts:

  • » [haiku-commits] Re: [haiku-commits] Re: r38086 -=D=A haiku/trunk/src/servers/app/drawing/Painter - pulkomandy