My opinion: yes, it is possible in C ++. There were several SO threads on this topic, none of which reached any solid conclusion. Here is one example .
, . - ; - . , , , - , " " .
struct
{
int a[2];
int b[2];
} foo;
if ( sizeof foo == 4 * sizeof(int) )
{
int *p = &foo.a[0];
++p;
++p;
*p = 3;
++p;
*p = 5;
}
undefined ( )? p (, ) int[2], foo.a.
(2), p . ?
+ ( p p = p + 1). ++ 11 [expr.add] # 7:
, undefined.
(2) UB . (3)?
, ++ , " ", undefined. , " ", " , ". : " ".
, , , , ; , p foo.b[0]. p foo.b, foo.a.
, C99 . C99 + ( ):
, ; undefined. , * , .
, C99 (3) undefined. ++ .
: , . " " C- , " ", . (), ; .
, C99 ; , (3).
, , ++ , ++ (3), UB; (4), (5).