From Jason Turner

[diff.cpp11.expr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpg9eqt9m3/{from.md → to.md} +34 -0
tmp/tmpg9eqt9m3/{from.md → to.md} RENAMED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Clause [[expr]]: expressions <a id="diff.cpp11.expr">[[diff.cpp11.expr]]</a>
2
+
3
+ [[expr.cond]] **Change:** A conditional expression with a throw
4
+ expression as its second or third operand keeps the type and value
5
+ category of the other operand. **Rationale:** Formerly mandated
6
+ conversions (lvalue-to-rvalue ([[conv.lval]]), array-to-pointer (
7
+ [[conv.array]]), and function-to-pointer ([[conv.func]]) standard
8
+ conversions), especially the creation of the temporary due to
9
+ lvalue-to-rvalue conversion, were considered gratuitous and surprising.
10
+ **Effect on original feature:** Valid C++11code that relies on the
11
+ conversions may behave differently in this International Standard:
12
+
13
+ ``` cpp
14
+ struct S {
15
+ int x = 1;
16
+ void mf() { x = 2; }
17
+ };
18
+ int f(bool cond) {
19
+ S s;
20
+ (cond ? s : throw 0).mf();
21
+ return s.x;
22
+ }
23
+ ```
24
+
25
+ In C++11, `f(true)` returns `1`. In this International Standard, it
26
+ returns `2`.
27
+
28
+ ``` cpp
29
+ sizeof(true ? "" : throw 0)
30
+ ```
31
+
32
+ In C++11, the expression yields `sizeof(const char*)`. In this
33
+ International Standard, it yields `sizeof(const char[1])`.
34
+