Skip to content

Repo sync for protected branch #5602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 30, 2025
Merged
2 changes: 1 addition & 1 deletion docs/build/reference/oi-generate-intrinsic-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For more information about which functions have intrinsic forms, see [intrinsic]
**/Oi** is only a request to the compiler to replace some function calls with intrinsics. The compiler may call the function (and not replace the function call with an intrinsic) if it results in better performance.\
**/Oi-** turns off this behavior, which may be useful if `/Oi` has been specified elsewhere and you want to override it.

You also use [intrinsic](../../preprocessor/intrinsic.md) to create intrinsic functions, or [function (C/C++)](../../preprocessor/function-c-cpp.md) to explicitly force a function call.
You can use [intrinsic](../../preprocessor/intrinsic.md) to create intrinsic functions, or [function (C/C++)](../../preprocessor/function-c-cpp.md) to explicitly force a function call.

### x86-specific remarks

Expand Down
5 changes: 3 additions & 2 deletions docs/sanitizers/error-memcpy-param-overlap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ helpviewer_keywords: ["memcpy-param-overlap error", "AddressSanitizer error memc

> Address Sanitizer Error: memcpy-param-overlap

> [!NOTE]
> The `/Oi` flag is required to reliably detect `memcpy-param-overlap` errors. This flag tells the compiler to treat `memcpy` and other functions as intrinsics, which is necessary because some versions of the standard library implement them as such. Since ASan is a dynamic analysis tool, it can only detect errors with an observable runtime effect. Note that when `/O2` is also set, ASan may not be able to reliably detect `memcpy-param-overlap` errors because the intrinsic variant of these functions isn't guaranteed to be used. For more information, see [`/Oi` docs](../build/reference/oi-generate-intrinsic-functions.md).

The CRT function [`memcpy`](../c-runtime-library/reference/memcpy-wmemcpy.md) **doesn't support** overlapping memory. The CRT provides an alternative to `memcpy` that does support overlapping memory: [`memmove`](../c-runtime-library/reference/memmove-wmemmove.md).

A common error is to treat `memmove` as being semantically equivalent to `memcpy`.
Expand Down Expand Up @@ -39,8 +42,6 @@ cl example1.cpp /fsanitize=address /Zi /Oi
devenv /debugexe example1.exe
```

The [/Oi flag](../build/reference/oi-generate-intrinsic-functions.md) tells the compiler to treat `memcpy` and `memmove` as intrinsic functions. This is necessary because some versions of the standard library implement `memcpy` and `memmove` in the same way. Because ASAN is a dynamic analysis tool, it only detects errors with an observable runtime effect.

### Resulting error

:::image type="content" source="media/memcpy-param-overlap-example-1.png" alt-text="Screenshot of debugger displaying memcpy-param-overlap error in example 1.":::
Expand Down