- Title
- Aliasing and qualification conversions
- Status
- cd1
- Section
- 7.2.1 [basic.lval]
- Submitter
- Mike Stump
Created on 1999-08-20.00:00:00 last changed 217 months ago
Messages
Date: 2002-04-15.00:00:00
[Moved to DR at 4/02 meeting.]
Date: 2001-04-15.00:00:00
Proposed resolution (04/01): Add a new bullet to 7.2.1 [basic.lval] paragraph 15,
following "a cv-qualified version of the dynamic type of the
object:"
Date: 2026-07-25.21:52:10
7.2.1 [basic.lval] paragraph 15 lists the types via which
an lvalue can be used to access the stored value of an object; using
an lvalue type that is not listed results in undefined behavior. It
is permitted to add cv-qualification to the actual type of the object
in this access, but only at the top level of the type ("a cv-qualified
version of the dynamic type of the object"). However, 7.3.6 [conv.qual] paragraph 4 permits a
"conversion [to] add cv-qualifiers at levels other than the first in
multi-level pointers." The combination of these two rules
allows creation of pointers that cannot be dereferenced without
causing undefined behavior. For instance: The reason that *p1 results in undefined behavior
is that the type of the lvalue is const int * const" ,
which is not "a cv-qualified version of" int* . Since the conversion is permitted, we must give it defined
semantics, hence we need to fix the wording in 7.2.1 [basic.lval] to include all possible conversions of the type via
7.3.6 [conv.qual].
int* jp;
const int * const * p1 = &jp;
*p1; // undefined behavior!
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
| 2003-04-25 00:00:00 | admin | set | status: dr -> wp |
| 2002-05-10 00:00:00 | admin | set | messages: + msg664 |
| 2002-05-10 00:00:00 | admin | set | status: ready -> dr |
| 2001-11-09 00:00:00 | admin | set | status: review -> ready |
| 2001-05-20 00:00:00 | admin | set | messages: + msg484 |
| 2001-05-20 00:00:00 | admin | set | status: open -> review |
| 1999-08-20 00:00:00 | admin | create | |