Created on 2004-12-15.00:00:00 last changed 207 months ago
[Voted into WP at April, 2006 meeting.]
Proposed resolution (April, 2005):
Change the second sentence of 7.6.1.8 [expr.typeid] paragraph 4 as follows:
If the type of the type-id is a reference to a possibly cv-qualified type, the result of the typeid expression refers to a std::type_info object representing the cv-unqualified referenced type.
There is an inconsistency between the normative text in section 7.6.1.8 [expr.typeid] and the example that follows.
Here is the relevant passage (starting with paragraph 4):
When typeid is applied to a type-id, the result refers to a std::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 std::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.
My proposal is that the strict reading of the normative test is correct. The example is wrong. Different compilers here give different answers.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
| 2006-11-05 00:00:00 | admin | set | status: dr -> wp |
| 2006-04-22 00:00:00 | admin | set | messages: + msg1362 |
| 2006-04-22 00:00:00 | admin | set | status: ready -> dr |
| 2005-10-22 00:00:00 | admin | set | status: review -> ready |
| 2005-05-01 00:00:00 | admin | set | messages: + msg1143 |
| 2005-05-01 00:00:00 | admin | set | status: open -> review |
| 2004-12-15 00:00:00 | admin | create | |