Topic: Inconsistency in typeid in standard.
Author: ascott@hochikieurope.com (Adam)
Date: Thu, 18 Nov 2004 18:01:34 GMT Raw View
Hi,
The next line of the quoted paragraph says:
"If the type of the type-id is a class type or a reference to a class
type, the class shall be completely-defined."
In this case, wouldn't the cv-qualifier refer to the 'D&' ?
Adam.
---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]
Author: ron@sensor.com (Ron Natalie)
Date: Fri, 19 Nov 2004 16:31:45 GMT Raw View
Adam wrote:
> Hi,
>
> The next line of the quoted paragraph says:
>
> "If the type of the type-id is a class type or a reference to a class
> type, the class shall be completely-defined."
>
> In this case, wouldn't the cv-qualifier refer to the 'D&' ?
>
That is my point. The standard literally reads that
typeid (const D&) != typeid (D&)
becuase there is no top-level cv-qualifier of the operand (not the type refered to
by the a reference type).
However the example says exactly the opposite, and I've got
compilers here that work both ways.
The example needs to be corrected, or if the real behavior is the other
way, the normative text needs to be fixed.
---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]
Author: ron@sensor.com (Ron Natalie)
Date: Mon, 15 Nov 2004 19:17:05 GMT Raw View
[NOTE: I'm reposting this as it seems to have never made it
to the group.]
While answering someone else's question on comp.lang.c++, I have
found a defect in the standard. Either the normative text is
wrong or the example is wrong for typeid.
Here are the relevant passage:
When typeid is applied to a type-id, the result refers to a type_info
object representing the type of the type-id. If the type of the type-id
is a reference type, the result of the typeid expression refers to a
type_info object representing the referenced type.
The top-level cv-qualifiers of the lvalue expression or the type-id that
is the operand of typeid are always ignored.
and the example:
typeid(D) == typeid(const D&); // yields true
The second paragraph above says the "type-id that is the operand".
This would be "const D&." In this case, the const is not at the
top-level (i.e., applied to the operand itself).
By a strict reading, the above should yield false.
To further confuse the issues, different compilers here give different
answers to the above expression.
If the the example is the correct behavior, then the second paragraph
needs to be tied in more explicitly to the "reference removal" in the
previous paragraph.
---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]