Actually you are very close to describing such a case! If you start with something like:Sven Schüle wrote:Could you give a concrete example how your "aliasing" situation could look like in order to create different behaviour between left-to-right and right-to-left evaluation of the operands of == in the expression "*++scan == *++match", where scan and match are both pointers?
If I understand you correctly you say that something likecould create such a problem. But even in this case the modification '++scan' does not change the contents of the 'match' variable. This would be the case only when dealing with references instead of pointers, which is not given here.Code: Select all
scan = (unsigned char *) &match;
Code: Select all
scan = (unsigned char *) &match;Consider this sub-expression:
Code: Select all
(*++scan == *++match) (1) increment scan, dereference scan, increment match, dereference match, compare the two dereferenced values [notice that this one increments match after scan is dereferenced]
(2) increment match, dereference match, increment scan, dereference scan, compare the two dereferenced values
(3) increment scan, increment match, dereference scan, dereference match, compare the two dereferenced values [notice that this one increments match before scan is dereferenced]
[Edit: I think section "6.5 Expressions" of the standard, allows any "character type" lvalue expression to access any part of any object. In other words char*, unsigned char* and signed char* must all be assumed to alias with anything, because they are pointers to a "character type". I found that in the article mentioned below]
Code: Select all
An object shall have its stored value accessed only by an lvalue expression that has one of the following types:
* a type compatible with the effective type of the object,
* a qualified version of a type compatible with the effective type of the object,
* a type that is the signed or unsigned type corresponding to the effective type of the object,
* a type that is the signed or unsigned type corresponding to a qualified version of the effective type of the object,
* an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), or
* a character type.
http://cellperformance.beyond3d.com/art ... asing.html
