Skip to content

Commit b755513

Browse files
authored
Merge pull request MicrosoftDocs#4755 from Rageking8/update-c3551
Update C3551
2 parents 2d39289 + 8f04cd5 commit b755513

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
---
22
description: "Learn more about: Compiler Error C3551"
33
title: "Compiler Error C3551"
4-
ms.date: "11/04/2016"
4+
ms.date: "10/07/2023"
55
f1_keywords: ["C3551"]
66
helpviewer_keywords: ["C3551"]
77
ms.assetid: c8ee23da-6568-40db-93a6-3ddb7ac47712
88
---
99
# Compiler Error C3551
1010

11-
"expected a late specified return type"
11+
if a trailing return type is used then the leading return type shall be the single type-specifier 'auto' (not 'type')
1212

13-
If you use the **`auto`** keyword as a placeholder for the return type of a function, you must provide a late-specified return type. In the following example, the late-specified return type of function `myFunction` is a pointer to an array of four elements of type **`int`**.
13+
The leading return type in [trailing return type](../../cpp/functions-cpp.md#trailing-return-types) syntax must contain only `auto`.
1414

15-
```
16-
auto myFunction()->int(*)[4];
17-
```
15+
```cpp
16+
// C3551.cpp
17+
// compile with: /c
18+
const auto func1() -> const int; // C3551
19+
auto* func2() -> int*; // C3551
20+
auto& func3() -> int&; // C3551
21+
auto&& func4() -> int&&; // C3551
22+
decltype(auto) func5() -> int; // C3551
1823

19-
## See also
20-
21-
[auto](../../cpp/auto-cpp.md)
24+
auto func6() -> int; // OK
25+
```

0 commit comments

Comments
 (0)