File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 30413041(for instance, via the C typedef in \libheaderref {stdbool.h })
30423042is ill-formed in \Cpp {}.
30433043
3044+ \diffref {expr.unary.op }
3045+ \change
3046+ In certain contexts,
3047+ taking the address of a dereferenced null or past-the-end pointer value
3048+ is well-defined in C (and yields the original pointer value),
3049+ but results in undefined behavior in \Cpp {}.
3050+ For example:
3051+ \begin {codeblock }
3052+ void f() {
3053+ char *p = nullptr;
3054+ char *p2 = &*p; // well-defined in C, undefined behavior in \Cpp {}
3055+ char *p3 = &p[0]; // well-defined in C, undefined behavior in \Cpp {}
3056+ int a[5];
3057+ int *q = &a[5]; // well-defined in C, undefined behavior in \Cpp {}
3058+ }
3059+ \end {codeblock }
3060+ \rationale
3061+ Consistent treatment of lvalues in \Cpp {}.
3062+ \effect
3063+ Well-formed and well-defined C code exhibits undefined behavior in \Cpp {}.
3064+ \difficulty
3065+ Syntactic transformation to pointer arithmetic
3066+ and possible addition of a check for null pointer values.
3067+ \howwide
3068+ Occasionally.
3069+
30443070\diffref {expr.sizeof,expr.cast }
30453071\change
30463072In \Cpp {}, types can only be defined in declarations, not in expressions.\\
You can’t perform that action at this time.
0 commit comments