[diff.cpp03.expr] (original) (raw)
Annex C (informative) Compatibility [diff]
C.6 C++ and ISO C++ 2003 [diff.cpp03]
C.6.3 [expr]: expressions [diff.cpp03.expr]
Affected subclause: [conv.ptr]
Change: Only literals are integer null pointer constants.
Rationale: Removing surprising interactions with templates and constant expressions.
Effect on original feature: Valid C++ 2003 code may fail to compile or produce different results in this revision of C++.
[Example 1: void f(void *); void f(...); template<int N> void g() { f(0*N); } — _end example_]
Affected subclause: [expr.typeid]
Change: Evaluation of operands in typeid.
Rationale: Introduce additional expression value categories.
Effect on original feature: Valid C++ 2003 code that uses xvalues as operands for typeidmay change behavior in this revision of C++.
[Example 2: void f() { struct B { B() {} virtual ~B() { } };struct C { B b; };typeid(C().b); } — _end example_]
Affected subclause: [expr.mul]
Change: Specify rounding for results of integer / and %.
Rationale: Increase portability, C99 compatibility.
Effect on original feature: Valid C++ 2003 code that uses integer division rounds the result toward 0 or toward negative infinity, whereas this revision of C++ always rounds the result toward 0.
Affected subclause: [expr.log.and]
Rationale: Required for new features.
Effect on original feature: Valid C++ 2003 code may fail to compile or produce different results in this revision of C++.
[Example 3: bool b1 = new int && false; struct S { operator int(); };bool b2 = &S::operator int && false; — _end example_]
Affected subclause: [expr.cond]
Change: Fewer copies in the conditional operator.
Rationale: Introduce additional expression value categories.
Effect on original feature: Valid C++ 2003 code that uses xvalues as operands for the conditional operator may change behavior in this revision of C++.
[Example 4: void f() { struct B { B() {} B(const B&) { } };struct D : B {};struct BB { B b; };struct DD { D d; };true ? BB().b : DD().d; } — _end example_]