Skip to content

Commit 17b96e9

Browse files
authored
Merge pull request #4926 from MicrosoftDocs/main
5/26 AM Publish
2 parents 70295ea + 2ca6ce5 commit 17b96e9

File tree

4 files changed

+76
-54
lines changed

4 files changed

+76
-54
lines changed

docs/c-runtime-library/reference/stat-functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
description: "Learn more about: _stat, _stat32, _stat64, _stati64, _stat32i64, _stat64i32, _wstat, _wstat32, _wstat64, _wstati64, _wstat32i64, _wstat64i32"
33
title: "_stat, _stat32, _stat64, _stati64, _stat32i64, _stat64i32, _wstat, _wstat32, _wstat64, _wstati64, _wstat32i64, _wstat64i32"
4-
ms.date: "4/2/2020"
4+
ms.date: "5/25/2023"
55
api_name: ["_wstat64", "_stati64", "_stat32", "_stat32i64", "_stat", "_wstati64", "_wstat32", "_wstat64i32", "_wstat", "_stat64", "_stat64i32", "_wstat32i64", "_o__stat32", "_o__stat32i64", "_o__stat64", "_o__stat64i32", "_o__wstat32", "_o__wstat32i64", "_o__wstat64", "_o__wstat64i32"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-filesystem-l1-1-0.dll"]
77
api_type: ["DLLExport"]
88
topic_type: ["apiref"]
99
f1_keywords: ["stat/_stat", "stat/_stat32", "stat/_stat32i64", "stat/_stat64", "stat/_stat64i32", "stat/_stati64", "stat/__stat64", "TCHAR/_tstat", "TCHAR/_tstat32", "TCHAR/_tstat32i64", "TCHAR/_tstat64", "TCHAR/_tstat64i32", "TCHAR/_tstati64", "stat/_wstat", "stat/_wstat32", "stat/_wstat32i64", "stat/_wstat64", "stat/_wstat64i32", "stat/_wstati64", "_stat", "_stat32", "_stat32i64", "_stat64", "_stat64i32", "_stati64", "__stat64", "_tstat", "_tstat32", "_tstat32i64", "_tstat64", "_tstat64i32", "_tstati64", "_wstat", "_wstat32", "_wstat32i64", "_wstat64", "_wstat64i32", "_wstati64", "stat", "stat32", "stat32i64", "stat64", "stat64i32", "stati64", "tstat", "tstat32", "tstat32i64", "tstat64", "tstat64i32", "tstati64", "wstat", "wstat32", "wstat32i64", "wstat64", "wstat64i32", "wstati64"]
1010
helpviewer_keywords: ["files [C++], status information", "_stat function", "_wstat function", "_stat64i32 function", "tstat function", "_tstat64i32 function", "_stati64 function", "_stat64 function", "tstati64 function", "wstati64 function", "wstat64 function", "_wstat64i32 function", "_tstat32i64 function", "_stat32i64 function", "stat function", "status of files", "_tstat32 function", "tstat64 function", "_wstat64 function", "_tstat function", "_stat32 function", "wstat function", "_wstat32i64 function", "_tstati64 function", "_wstat32 function", "stat64 function", "stati64 function", "_wstati64 function", "_tstat64 function", "files [C++], getting status information"]
11-
ms.assetid: 99a75ae6-ff26-47ad-af70-5ea7e17226a5
1211
---
1312
# `_stat`, `_stat32`, `_stat64`, `_stati64`, `_stat32i64`, `_stat64i32`, `_wstat`, `_wstat32`, `_wstat64`, `_wstati64`, `_wstat32i64`, `_wstat64i32`
1413

@@ -95,6 +94,7 @@ Variations of these functions support 32-bit or 64-bit time types, and 32-bit or
9594

9695
> [!NOTE]
9796
> **`_wstat`** does not work with Windows Vista symbolic links. In these cases, **`_wstat`** will always report a file size of 0. **`_stat`** does work correctly with symbolic links.
97+
> The `_stat`family of functions use `CreateFile` in Visual Studio 2015, instead of `FindFirstFile` as in Visual Studio 2013 and earlier. This means that `_stat` on a path ending with a slash succeeds if the path refers to a directory, as opposed to before when the function would error with `errno` set to `ENOENT`.
9898
9999
This function validates its parameters. If either *`path`* or *`buffer`* is `NULL`, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md).
100100

docs/code-quality/c33010.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ helpviewer_keywords: ["C33010"]
99
---
1010
# Warning C33010
1111

12-
> Unchecked lower bound for enum *enum_name* used as index.
12+
> Unchecked lower bound for enum 'enum' used as index.
1313
1414
This warning is triggered if an enum is both used as an index into an array and isn't checked on the lower bound.
1515

@@ -71,6 +71,31 @@ void foo(Index idx, PFN(&functions)[5])
7171
}
7272
```
7373

74+
Alternatively, the issue can be fixed by choosing an underlying type for `Index` that is unsigned. Because an unsigned value is always positive, it is sufficient to only check the upper bound.
75+
76+
```cpp
77+
typedef void (*PFN)();
78+
79+
enum class Index : unsigned int
80+
{
81+
Zero,
82+
One,
83+
Two,
84+
Three,
85+
Max
86+
};
87+
88+
void foo(Index idx, PFN(&functions)[5])
89+
{
90+
if (idx > Index::Max)
91+
return;
92+
93+
auto pfn = functions[static_cast<unsigned int>(idx)];
94+
if (pfn != nullptr)
95+
(*pfn)();
96+
}
97+
```
98+
7499
## See also
75100
76101
[C33011](./c33011.md)

docs/code-quality/c33011.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: C33011 warning for enums
44
author: hwisungi
55
ms.author: hwisungi
66
ms.date: 06/20/2020
7-
f1_keywords: ["C33011", "UNCHECKED_UPPER_BOUND_FOR_ENUMINDEX"]
7+
f1_keywords: ["C33011", "UNCHECKED_UPPER_BOUND_FOR_ENUMINDEX", "__WARNING_UNCHECKED_UPPER_BOUND_FOR_ENUMINDEX"]
88
helpviewer_keywords: ["C33011"]
99
---
1010
# Warning C33011

0 commit comments

Comments
 (0)