Topic: Where in the standard does it say PODs can have no virtual functions?


Author: "Darin Adler" <darin@bentspoon.com>
Date: 1999/07/30
Raw View
I searched the standard for the definition of "POD". I found a few key
paragraphs:

    3.9/10 defines "POD type".
    9/4 defines "POD-struct" and "POD-union".

But I can't find anything that says a POD-struct may not contain any virtual
functions. Is that in there somewhere?

Someone once told me that you also can't have any constructors for a POD. I
didn't see that earlier. Where is it?

    -- Darin


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: clamage@eng.sun.com (Steve Clamage)
Date: 1999/07/30
Raw View
"Darin Adler" <darin@bentspoon.com> writes:

>I searched the standard for the definition of "POD". I found a few key
>paragraphs:

>    3.9/10 defines "POD type".
>    9/4 defines "POD-struct" and "POD-union".

>But I can't find anything that says a POD-struct may not contain any virtual
>functions. Is that in there somewhere?

Notice that 9/4 says a POD-struct is an aggregate struct, and refers
you to 8.5.1 for the definition of aggregate.

Aggregates have restrictions; 9/4 just lists the additional
restrictions of PODs.

--
Steve Clamage, stephen.clamage@sun.com


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: comeau@panix.com (Greg Comeau)
Date: 1999/07/31
Raw View
In article <7nsl2j$1db5@enews3.newsguy.com> "Darin Adler" <darin@bentspoon.com> writes:
>
>I searched the standard for the definition of "POD". I found a few key
>paragraphs:
>
>    3.9/10 defines "POD type".
>    9/4 defines "POD-struct" and "POD-union".
>
>But I can't find anything that says a POD-struct may not contain any virtual
>functions. Is that in there somewhere?

An aggregate cannot have virtual functions.
A POD is an aggregate.

>Someone once told me that you also can't have any constructors for a POD. I
>didn't see that earlier. Where is it?

An aggregate cannot have user-defined ctors.
A POD is an aggregate.

Check out..... 8.5.1.

- Greg
--
       Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
     Producers of Comeau C/C++ 4.2.38 -- New Release!  We now do Windows too.
    Email: comeau@comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
                *** WEB: http://www.comeaucomputing.com ***
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: miker3@ix.netcom.com (Michael Rubenstein)
Date: 1999/07/31
Raw View
On 30 Jul 1999 16:55:58 GMT, "Darin Adler" <darin@bentspoon.com>
wrote:

>
>I searched the standard for the definition of "POD". I found a few key=20
>paragraphs:
>
>    3.9/10 defines "POD type".
>    9/4 defines "POD-struct" and "POD-union".
>
>But I can't find anything that says a POD-struct may not contain any vir=
tual
>functions. Is that in there somewhere?
>
>Someone once told me that you also can't have any constructors for a POD=
. I
>didn't see that earlier. Where is it?

>From 9:

 A POD=ADstruct is an aggregate class ...

>From 8.5.1:

 An aggregate is an array or a class (clause 9) with no=20
 user=ADdeclared constructors (12.1), no private or=20
 protected non=ADstatic data members (clause 11), no base=20
 classes (clause 10), and no virtual functions (10.3).
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: 1999/07/31
Raw View
Darin Adler wrote:
>
> I searched the standard for the definition of "POD". I found a few key
> paragraphs:
>
>     3.9/10 defines "POD type".
>     9/4 defines "POD-struct" and "POD-union".
>
> But I can't find anything that says a POD-struct may not contain any virtual
> functions. Is that in there somewhere?
>
> Someone once told me that you also can't have any constructors for a POD. I
> didn't see that earlier. Where is it?

Many people (I was one) fail to notice on their first (few) reading(s)
that the word 'aggregate' used in 9/4 is a technical term, defined in
8.5.1. The standard even contains a cross-reference to 8.5.1 in 9/4, but
that doesn't seem to help. The very first paragraph of 8.5.1 rules out
virtual functions and user-declared constructors.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]