You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/pow-powf-powl.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,8 @@ If you use the \<tgmath.h> `pow()` macro, the type of the argument determines wh
59
59
60
60
The `pow(int, int)` overload is no longer available. If you use this overload, the compiler may emit [C2668](../../error-messages/compiler-errors-2/compiler-error-c2668.md). To avoid this problem, cast the first parameter to **`double`**, **`float`**, or **`long double`**.
61
61
62
+
Originally, the `pow(T, int)` overloads would unroll the `pow` call into a sequence of inline multiplication operations. While this was faster, it was also significantly less accurate and was removed in Visual Studio 2015 Update 1. For more information, see [Conformance Improvements in Visual Studio 2015 Update 1](../../porting/visual-cpp-what-s-new-2003-through-2015.md).
63
+
62
64
By default, this function's global state is scoped to the application. To change this, see [Global state in the CRT](../global-state.md).
Copy file name to clipboardExpand all lines: docs/porting/visual-cpp-what-s-new-2003-through-2015.md
+30-4Lines changed: 30 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ Although these differences can affect your source code or other build artifacts,
122
122
}
123
123
```
124
124
125
-
The current compiler correctly gives an error, because the template parameter type doesn't match the template argument (the parameter is a pointer to a const member, but the function f is non-const):
125
+
The current compiler correctly gives an error, because the template parameter type does not match the template argument (the parameter is a pointer to a const member, but the function f is non-const):
126
126
127
127
```Output
128
128
error C2893: Failed to specialize function template 'void S2::f(void)'note: With the following template arguments:note: 'C=S1'note: 'Function=S1::f'
@@ -581,7 +581,7 @@ Although these differences can affect your source code or other build artifacts,
Additionally, although the compiler doesn't give a specific diagnostic, inline operator new is considered ill-formed.
584
+
Additionally, although the compiler does not give a specific diagnostic, inline operator new is considered ill-formed.
585
585
586
586
-**Calling 'operator *type*()' (user-defined conversion) on non-class types** Previous versions of the compiler allowed 'operator *type*()' to be called on non-class types while silently ignoring it. This old behavior created a risk of silent bad code generation, resulting in unpredictable runtime behavior. The compiler no longer accepts code written in this way and issues compiler error C2228 instead.
587
587
@@ -1008,11 +1008,37 @@ Although these differences can affect your source code or other build artifacts,
1008
1008
}
1009
1009
```
1010
1010
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 <classT>
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
+
1011
1037
### <a name="VS_Update2"></a> Conformance Improvements in Visual Studio 2015 Update 2
1012
1038
1013
1039
- **Additional warnings and errors might be issued as a result of partial support for expression SFINAE**
1014
1040
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.
1016
1042
1017
1043
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.
1018
1044
@@ -1185,7 +1211,7 @@ Although these differences can affect your source code or other build artifacts,
1185
1211
1186
1212
-**Forward declaration of enum is not allowed in WinRT code** (affects `/ZW` only)
1187
1213
1188
-
Code compiled for the Windows Runtime (WinRT) doesn't allow **`enum`** types to be forward declared, similarly to when managed C++ code is compiled for the .Net Framework using the `/clr` compiler switch. This behavior is ensures that the size of an enumeration is always known and can be correctly projected to the WinRT type system. The compiler rejects code written in this way and issues compiler error C2599 together with compiler error C3197.
1214
+
Code compiled for the Windows Runtime (WinRT) does not allow **`enum`** types to be forward declared, similarly to when managed C++ code is compiled for the .Net Framework using the `/clr` compiler switch. This behavior is ensures that the size of an enumeration is always known and can be correctly projected to the WinRT type system. The compiler rejects code written in this way and issues compiler error C2599 together with compiler error C3197.
1189
1215
1190
1216
```Output
1191
1217
error C2599: 'CustomEnum': the forward declaration of a WinRT enum is not allowed
0 commit comments