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/cpp/attributes.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,19 +160,19 @@ void f() {
160
160
```
161
161
### `[[msvc::musttail]]`
162
162
163
-
The `[[msvc::musttail]]` attribute is an experimental x64 only Microsoft-specific attribute that enforces tail-call optimization for a given function call. When applied on a qualifying return statement, it instructs the compiler to emit the call as a tail call. If the compiler cannot do so, it will produce a compilation error. The `[[msvc::musttail]]` attribute will enforce tail calling over inlining of a function.
163
+
The `[[msvc::musttail]]` attribute is an experimental x64 only Microsoft-specific attribute introduced in [MSVC Build Tools version 14.50](https://learn.microsoft.com/en-us/cpp/overview/what-s-new-for-msvc?view=msvc-170)that enforces tail-call optimization for a given function call. When applied on a qualifying return statement, it instructs the compiler to emit the call as a tail call. If the compiler cannot do so, it will produce a compilation error. The `[[msvc::musttail]]` attribute will enforce tail calling over inlining of a function.
164
164
165
165
The `[[msvc::musttail]]` attribute has constraints:
166
166
- The caller and callee must have matching return types.
167
167
- The calling conventions must be compatible.
168
-
- The tail call must be in the return position (i.e., the final action in the calling function).
168
+
- The tail call must be the final action in the calling function.
169
169
- The callee must not use more stack space than the calling function.
170
-
- If more than 4 integer parameters are passed, the calling function must allocate enough stack space for those additional arguments. Please see __preserve_none calling convention for tail calling without additional stack overhead.
171
-
-Other compiler optimizations must be enabled.
170
+
- If more than four integer parameters are passed, the calling function must allocate enough stack space for those additional arguments. Please see `__preserve_none` calling convention for tail calling without additional stack overhead.
171
+
-Must compile with `/O2` or `/O2 /GL` optimization level
172
172
173
173
#### Example
174
174
175
-
In this sample code, the `[[msvc::musttail]]` attribute applied to the return bar function call forces execution to jump from foo to bar before returning to main, rather than inlining bar into foo or calling bar from foo and returning to foo before returning to main.
175
+
In the follwoing code, the `[[msvc::musttail]]` attribute applied to the `return bar(x)`call forces execution to jump from `foo` to `bar` before returning to `main`, rather than inlining `bar` into `foo` or calling `bar` from `foo` and returning to `foo` before returning to `main`.
0 commit comments