Topic: Ill-defined term "access path


Author: David Krauss <potswa@gmail.com>
Date: Sun, 15 Aug 2010 15:35:57 CST
Raw View
FCD sections 7.1.6.1 [dcl.type.cv] and 9.3.2 [class.this] use the term
"access path" occasionally without really defining it. Apparently an
access path is formed either by a pointer or reference variable or
implicitly through "this."

Without defining the term, it is possible to misconstrue "const access
path" as one where const appears anywhere, not just referring to the
accessed object. For example,

int i;

struct A {
   int *x;
   A() : x( &i ) {}
} const a;

void f() {
   a->x = 5; // non-const access path to i involving const objects
}

This is unlikely to cause serious or widespread confusion, but see
http://stackoverflow.com/questions/3484233/const-method-that-modifies-this-without-const-cast/3484265#3484265
for an example of the wording causing a problem.

--
[ 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]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]