Topic: Defect Report: type of decltype(e) not clearly enough defined


Author: "Johannes Schaub (litb)" <schaub-johannes@web.de>
Date: Sun, 17 Jan 2010 01:11:08 CST
Raw View
I'm aware of closed issue #669, but i think there are still issues left.
7.1.6.2[dcl.type.simple] paragraph 4 does say for decltype(e):

"if e is an unparenthesized id-expression or a class member access (5.2.5),
decltype(e) is the type of the entity named by e."

This is not sufficient clear, as the following code illustrates

struct A {
 int m;
};

A const a = { };
decltype(a.m) i;

The type of the object/class-member named by "a.m" definitely is const
qualified (we are also not allowed to write to it without undefined
behavior, by the same reason). Consequently the type of 'i' is "const int".
However the intent may be that the declared type of "a.m" is taken, and not
the type as influenced by other factors.

The example in that paragraph does not contradict the interpretation here,
because the example accesses "a->x", which is a non-const object.

If we change this to "declared type", we will have to clarify what this
means for parameters of functions: Will "declared type" apply to the type
after or before parameter type transformations? (18.10[support.runtime]
paragraph 3 seems to make it refer to before the transformations).

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]