Jump to page: 1 2
Thread overview
Catch slicing
Aug 18, 2003
Matthew Wilson
Aug 21, 2003
Walter
Aug 21, 2003
Matthew Wilson
Aug 22, 2003
Walter
Aug 22, 2003
Matthew Wilson
Aug 22, 2003
Matthew Wilson
Aug 22, 2003
Heinz Saathoff
Aug 22, 2003
Matthew Wilson
Aug 25, 2003
Walter
Aug 25, 2003
Heinz Saathoff
Aug 25, 2003
Matthew Wilson
Aug 27, 2003
Philippe Mori
Aug 27, 2003
Matthew Wilson
Aug 29, 2003
Philippe Mori
August 18, 2003
Walter

How hard would it be to add a (non-default, I suppose) flag (-wxs) to warn
when catching by value for non-fundamental, or for non-POD, types, as in:

class A
{};

class B
  : public A
{};

try
{
  throw B()
}
catch(A a) // "Warning: Catch clause type is by value for polymorphic type"
{

}

It'd be sweet (and would get DMC++ a special mention in Part 5, which I may
do next).

Matthew


August 21, 2003
It's not so easy to tell that a class has been derived from, such as if class B is in another file.

"Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bhpg7o$1sfb$1@digitaldaemon.com...
> Walter
>
> How hard would it be to add a (non-default, I suppose) flag (-wxs) to warn
> when catching by value for non-fundamental, or for non-POD, types, as in:
>
> class A
> {};
>
> class B
>   : public A
> {};
>
> try
> {
>   throw B()
> }
> catch(A a) // "Warning: Catch clause type is by value for polymorphic
type"
> {
>
> }
>
> It'd be sweet (and would get DMC++ a special mention in Part 5, which I
may
> do next).
>
> Matthew
>
>


August 21, 2003
I appreciate that, but surely it's possible to readily deduce that a non-POD type is being caught by value?

"Walter" <walter@digitalmars.com> wrote in message news:bi1l46$1lbs$4@digitaldaemon.com...
> It's not so easy to tell that a class has been derived from, such as if class B is in another file.
>
> "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bhpg7o$1sfb$1@digitaldaemon.com...
> > Walter
> >
> > How hard would it be to add a (non-default, I suppose) flag (-wxs) to
warn
> > when catching by value for non-fundamental, or for non-POD, types, as
in:
> >
> > class A
> > {};
> >
> > class B
> >   : public A
> > {};
> >
> > try
> > {
> >   throw B()
> > }
> > catch(A a) // "Warning: Catch clause type is by value for polymorphic
> type"
> > {
> >
> > }
> >
> > It'd be sweet (and would get DMC++ a special mention in Part 5, which I
> may
> > do next).
> >
> > Matthew
> >
> >
>
>


August 22, 2003
What's a POD?

"Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bi1piu$1rrj$1@digitaldaemon.com...
> I appreciate that, but surely it's possible to readily deduce that a
non-POD
> type is being caught by value?
>
> "Walter" <walter@digitalmars.com> wrote in message news:bi1l46$1lbs$4@digitaldaemon.com...
> > It's not so easy to tell that a class has been derived from, such as if class B is in another file.
> >
> > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bhpg7o$1sfb$1@digitaldaemon.com...
> > > Walter
> > >
> > > How hard would it be to add a (non-default, I suppose) flag (-wxs) to
> warn
> > > when catching by value for non-fundamental, or for non-POD, types, as
> in:
> > >
> > > class A
> > > {};
> > >
> > > class B
> > >   : public A
> > > {};
> > >
> > > try
> > > {
> > >   throw B()
> > > }
> > > catch(A a) // "Warning: Catch clause type is by value for polymorphic
> > type"
> > > {
> > >
> > > }
> > >
> > > It'd be sweet (and would get DMC++ a special mention in Part 5, which
I
> > may
> > > do next).
> > >
> > > Matthew
> > >
> > >
> >
> >
>
>


August 22, 2003
Plain Old Data. Stuff with ctors/dtors/copy-assignment ops/etc.

I'm pretty sure it's defined in the standard. I'll have a look.

"Walter" <walter@digitalmars.com> wrote in message news:bi4cq6$2n5h$1@digitaldaemon.com...
> What's a POD?
>
> "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bi1piu$1rrj$1@digitaldaemon.com...
> > I appreciate that, but surely it's possible to readily deduce that a
> non-POD
> > type is being caught by value?
> >
> > "Walter" <walter@digitalmars.com> wrote in message news:bi1l46$1lbs$4@digitaldaemon.com...
> > > It's not so easy to tell that a class has been derived from, such as
if
> > > class B is in another file.
> > >
> > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bhpg7o$1sfb$1@digitaldaemon.com...
> > > > Walter
> > > >
> > > > How hard would it be to add a (non-default, I suppose) flag (-wxs)
to
> > warn
> > > > when catching by value for non-fundamental, or for non-POD, types,
as
> > in:
> > > >
> > > > class A
> > > > {};
> > > >
> > > > class B
> > > >   : public A
> > > > {};
> > > >
> > > > try
> > > > {
> > > >   throw B()
> > > > }
> > > > catch(A a) // "Warning: Catch clause type is by value for
polymorphic
> > > type"
> > > > {
> > > >
> > > > }
> > > >
> > > > It'd be sweet (and would get DMC++ a special mention in Part 5,
which
> I
> > > may
> > > > do next).
> > > >
> > > > Matthew
> > > >
> > > >
> > >
> > >
> >
> >
>
>


August 22, 2003
3.9

"Matthew Wilson" <dmd@synesis.com.au> wrote in message news:bi4cta$2n97$1@digitaldaemon.com...
> Plain Old Data. Stuff with ctors/dtors/copy-assignment ops/etc.
>
> I'm pretty sure it's defined in the standard. I'll have a look.
>
> "Walter" <walter@digitalmars.com> wrote in message news:bi4cq6$2n5h$1@digitaldaemon.com...
> > What's a POD?
> >
> > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bi1piu$1rrj$1@digitaldaemon.com...
> > > I appreciate that, but surely it's possible to readily deduce that a
> > non-POD
> > > type is being caught by value?
> > >
> > > "Walter" <walter@digitalmars.com> wrote in message news:bi1l46$1lbs$4@digitaldaemon.com...
> > > > It's not so easy to tell that a class has been derived from, such as
> if
> > > > class B is in another file.
> > > >
> > > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bhpg7o$1sfb$1@digitaldaemon.com...
> > > > > Walter
> > > > >
> > > > > How hard would it be to add a (non-default, I suppose) flag (-wxs)
> to
> > > warn
> > > > > when catching by value for non-fundamental, or for non-POD, types,
> as
> > > in:
> > > > >
> > > > > class A
> > > > > {};
> > > > >
> > > > > class B
> > > > >   : public A
> > > > > {};
> > > > >
> > > > > try
> > > > > {
> > > > >   throw B()
> > > > > }
> > > > > catch(A a) // "Warning: Catch clause type is by value for
> polymorphic
> > > > type"
> > > > > {
> > > > >
> > > > > }
> > > > >
> > > > > It'd be sweet (and would get DMC++ a special mention in Part 5,
> which
> > I
> > > > may
> > > > > do next).
> > > > >
> > > > > Matthew
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


August 22, 2003
Matthew Wilson schrieb...
> 
> Plain Old Data. Stuff with ctors/dtors/copy-assignment ops/etc.
                        ^^^^
                      without

POD structs should only consist of simple data members. No member
functions at all.
POD type variables can be safely copied with memcopy.

- Heinz
August 22, 2003
Yes, it was a mistake.

And yes, I agree with all that you've said about POD

"Heinz Saathoff" <hsaat@bre.ipnet.de> wrote in message news:MPG.19afdfd9e86c795f9896ce@news.digitalmars.com...
> Matthew Wilson schrieb...
> >
> > Plain Old Data. Stuff with ctors/dtors/copy-assignment ops/etc.
>                         ^^^^
>                       without
>
> POD structs should only consist of simple data members. No member
> functions at all.
> POD type variables can be safely copied with memcopy.
>
> - Heinz


August 25, 2003
Hmm. I would think that a POD type would be defined by not having a vptr.

"Heinz Saathoff" <hsaat@bre.ipnet.de> wrote in message news:MPG.19afdfd9e86c795f9896ce@news.digitalmars.com...
> Matthew Wilson schrieb...
> >
> > Plain Old Data. Stuff with ctors/dtors/copy-assignment ops/etc.
>                         ^^^^
>                       without
>
> POD structs should only consist of simple data members. No member
> functions at all.
> POD type variables can be safely copied with memcopy.
>
> - Heinz


August 25, 2003
Walter schrieb...
> 
> Hmm. I would think that a POD type would be defined by not having a vptr.

Not only that struct but also included structs. The standard says that PODs are classic C-structs which makes sense. This also gives compiler writes more freedom in implementing things. For DMC I know that adding members isn't a problem and I still can memcpy such structs. But it's not guaranteed by the standard.

- Heinz
« First   ‹ Prev
1 2