Skip to content

Commit 39d2f34

Browse files
author
Steve Wishnousky
authored
Add pow_int change to VS 2015 Update 1 change list
1 parent c38a46c commit 39d2f34

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

‎docs/porting/visual-cpp-what-s-new-2003-through-2015.md‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,11 +1008,37 @@ Although these differences can affect your source code or other build artifacts,
10081008
}
10091009
```
10101010

1011+
- ** Removal of `pow(T, int)` unrolling optimization **
1012+
1013+
Previous versions of the C++ standard library defined a `pow(T, int)` function template that would unroll a `pow` function call into a series of multiplication operations. This technique would accrue a large amount of inaccuracy due to the nature of floating point operations, causing end results that could be significantly inaccurate. In Visual Studio 2015 Update 1, this behavior was removed to avoid unintentional loss of accuracy when using the `pow` function. However, this version of `pow` was much faster than the correct calculation. If this change causes a significant performance regression and your project does not require precise floating point results (for example, your project already compiles with /fp:fast), consider replacing calls to `pow` with this workaround function:
1014+
1015+
```cpp
1016+
template <class T>
1017+
inline T pow_int(T x, int y) throw() {
1018+
unsigned int n;
1019+
if (y >= 0) {
1020+
n = (unsigned int)(y);
1021+
} else {
1022+
n = (unsigned int)(-y);
1023+
}
1024+
for (T z = T(1); ; x *= x) {
1025+
if ((n & 1) != 0) {
1026+
z *= x;
1027+
}
1028+
if ((n >>= 1) == 0) {
1029+
return (y < 0 ? T(1) / z : z);
1030+
}
1031+
}
1032+
}
1033+
```
1034+
1035+
This implementation is identical to what was included in previous versions of Visual Studio.
1036+
10111037
### <a name="VS_Update2"></a> Conformance Improvements in Visual Studio 2015 Update 2
10121038
10131039
- **Additional warnings and errors might be issued as a result of partial support for expression SFINAE**
10141040
1015-
Previous versions of the compiler did not parse certain kinds of expressions inside **`decltype`** specifiers due to lack of support for expression SFINAE. This old behavior was incorrect and does not conform to the C++ standard. The compiler now parses these expressions and has partial support for expression SFINAE due to ongoing conformance improvements. As a result, the compiler now issues warnings and errors found in expressions that previous versions of the compiler did not parse.
1041+
Previous versions of the compiler did not parse certain kinds of expressions inside **`decltype`** specifiers due to lack of support for expression SFINAE. This old behavior was incorrect and does not conform to the C++ standard. The compiler now parses these expressions and has partial support for expression SFINAE due to ongoing conformance improvements. As a result, the compiler now issues warnings and errors found in expressions that previous versions of the compiler did not parse.
10161042
10171043
When this new behavior parses a **`decltype`** expression that includes a type that has not yet been declared, the compiler issues compiler error C2039 as a result.
10181044

0 commit comments

Comments
 (0)