Re: Review Request 45489: Replaced reinterpret_cast with dynamic_cast in libprocess.

2016-03-30 Thread Benjamin Bannier


> On March 30, 2016, 5:03 p.m., Benjamin Bannier wrote:
> > 3rdparty/libprocess/src/process.cpp, line 1531
> > 
> >
> > Here and below: Either explicitly assert that the `dynamic_cast` does 
> > not return `NULL`, or use `static_cast`.
> > 
> > Since `Encoder` seems to implement its own idea of polymorphism it 
> > seems `static_cast` might fit better.
> 
> Neil Conway wrote:
> Hmmm -- I thought `static_cast` was only safe for downcasts when the 
> parent class is non-virtual?

It is fine for most cases, but cannot be used e.g., in the presence of virtual 
*inheritance* (which isn't used here).


- Benjamin


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/45489/#review126115
---


On March 30, 2016, 4:49 p.m., Neil Conway wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/45489/
> ---
> 
> (Updated March 30, 2016, 4:49 p.m.)
> 
> 
> Review request for mesos and Ben Mahler.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Casting from a parent class to a child class should not
> be done with reinterpret_cast.
> 
> 
> Diffs
> -
> 
>   3rdparty/libprocess/src/process.cpp 
> feaffa4334422ec3964f8d079f570061eaf390d2 
> 
> Diff: https://reviews.apache.org/r/45489/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Neil Conway
> 
>



Re: Review Request 45489: Replaced reinterpret_cast with dynamic_cast in libprocess.

2016-03-30 Thread Neil Conway


> On March 30, 2016, 3:03 p.m., Benjamin Bannier wrote:
> > 3rdparty/libprocess/src/process.cpp, line 1531
> > 
> >
> > Here and below: Either explicitly assert that the `dynamic_cast` does 
> > not return `NULL`, or use `static_cast`.
> > 
> > Since `Encoder` seems to implement its own idea of polymorphism it 
> > seems `static_cast` might fit better.

Hmmm -- I thought `static_cast` was only safe for downcasts when the parent 
class is non-virtual?


- Neil


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/45489/#review126115
---


On March 30, 2016, 2:49 p.m., Neil Conway wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/45489/
> ---
> 
> (Updated March 30, 2016, 2:49 p.m.)
> 
> 
> Review request for mesos and Ben Mahler.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Casting from a parent class to a child class should not
> be done with reinterpret_cast.
> 
> 
> Diffs
> -
> 
>   3rdparty/libprocess/src/process.cpp 
> feaffa4334422ec3964f8d079f570061eaf390d2 
> 
> Diff: https://reviews.apache.org/r/45489/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Neil Conway
> 
>



Re: Review Request 45489: Replaced reinterpret_cast with dynamic_cast in libprocess.

2016-03-30 Thread Benjamin Bannier

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/45489/#review126115
---




3rdparty/libprocess/src/process.cpp (line 1531)


Here and below: Either explicitly assert that the `dynamic_cast` does not 
return `NULL`, or use `static_cast`.

Since `Encoder` seems to implement its own idea of polymorphism it seems 
`static_cast` might fit better.


- Benjamin Bannier


On March 30, 2016, 4:49 p.m., Neil Conway wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/45489/
> ---
> 
> (Updated March 30, 2016, 4:49 p.m.)
> 
> 
> Review request for mesos and Ben Mahler.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Casting from a parent class to a child class should not
> be done with reinterpret_cast.
> 
> 
> Diffs
> -
> 
>   3rdparty/libprocess/src/process.cpp 
> feaffa4334422ec3964f8d079f570061eaf390d2 
> 
> Diff: https://reviews.apache.org/r/45489/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Neil Conway
> 
>