117 lines
3.5 KiB
Markdown
117 lines
3.5 KiB
Markdown
[diff.cpp03.expr]
|
||
|
||
# Annex C (informative) Compatibility [[diff]](./#diff)
|
||
|
||
## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#expr)
|
||
|
||
### C.6.3 [[expr]](expr "7 Expressions"): expressions [diff.cpp03.expr]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2198)
|
||
|
||
**Affected subclause:** [[conv.ptr]](conv.ptr)
|
||
|
||
|
||
**Change:** Only literals are integer null pointer constants[.](#1.sentence-1)
|
||
|
||
|
||
|
||
|
||
**Rationale:** Removing surprising interactions with templates and constant
|
||
expressions[.](#1.sentence-2)
|
||
|
||
|
||
|
||
|
||
**Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in
|
||
this revision of C++[.](#1.sentence-3)
|
||
|
||
[*Example [1](#example-1)*: void f(void *); // #1void f(...); // #2template<int N> void g() { f(0*N); // calls #2; used to call #1} â *end example*]
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2217)
|
||
|
||
**Affected subclause:** [[expr.typeid]](expr.typeid)
|
||
|
||
|
||
**Change:** Evaluation of operands in typeid[.](#2.sentence-1)
|
||
|
||
|
||
|
||
|
||
**Rationale:** Introduce additional expression value categories[.](#2.sentence-2)
|
||
|
||
|
||
|
||
|
||
**Effect on original feature:** Valid C++ 2003 code that uses xvalues as operands for typeid may change behavior in this revision of C++[.](#2.sentence-3)
|
||
|
||
[*Example [2](#example-2)*: void f() {struct B { B() {}virtual ~B() { }}; struct C { B b; }; typeid(C().b); // unevaluated in C++ 2003, evaluated in C++ 2011} â *end example*]
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2239)
|
||
|
||
**Affected subclause:** [[expr.mul]](expr.mul)
|
||
|
||
|
||
**Change:** Specify rounding for results of integer / and %[.](#3.sentence-1)
|
||
|
||
|
||
|
||
|
||
**Rationale:** Increase portability, C99 compatibility[.](#3.sentence-2)
|
||
|
||
|
||
|
||
|
||
**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[.](#3.sentence-3)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2249)
|
||
|
||
**Affected subclause:** [[expr.log.and]](expr.log.and)
|
||
|
||
|
||
**Change:** && is valid in a [*type-name*](dcl.type.simple#nt:type-name "9.2.9.3 Simple type specifiers [dcl.type.simple]")[.](#4.sentence-1)
|
||
|
||
|
||
|
||
|
||
**Rationale:** Required for new features[.](#4.sentence-2)
|
||
|
||
|
||
|
||
|
||
**Effect on original feature:** Valid C++ 2003 code may fail to compile or produce different results in
|
||
this revision of C++[.](#4.sentence-3)
|
||
|
||
[*Example [3](#example-3)*: bool b1 = new int && false; // previously false, now ill-formedstruct S { operator int(); };bool b2 = &S::operator int && false; // previously false, now ill-formed â *end example*]
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2265)
|
||
|
||
**Affected subclause:** [[expr.cond]](expr.cond)
|
||
|
||
|
||
**Change:** Fewer copies in the conditional operator[.](#5.sentence-1)
|
||
|
||
|
||
|
||
|
||
**Rationale:** Introduce additional expression value categories[.](#5.sentence-2)
|
||
|
||
|
||
|
||
|
||
**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++[.](#5.sentence-3)
|
||
|
||
[*Example [4](#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; // additional copy in C++ 2003, no copy or move in C++ 2011} â *end example*]
|