Skip to content

Commit 387c8c7

Browse files
Ron PetrushaBillWagner
Ron Petrusha
authored andcommitted
Issue 1846: goto must go to a constant label (dotnet#2801)
1 parent 982c2b0 commit 387c8c7

File tree

1 file changed

+1
-1
lines changed
  • docs/csharp/language-reference/keywords

1 file changed

+1
-1
lines changed

docs/csharp/language-reference/keywords/switch.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ This requirement is usually met by explicitly exiting the switch section by usin
9494

9595
[!code-cs[switch#4](../../../../samples/snippets/csharp/language-reference/keywords/switch/switch4.cs#1)]
9696

97-
Execution of the statement list in the switch section with a case label that matches the match expression begins with the first statement and proceeds through the statement list, typically until a jump statement, such as a `break`, `goto case`, `return`, or `throw`, is reached. At that point, control is transferred outside the `switch` statement or to another case label.
97+
Execution of the statement list in the switch section with a case label that matches the match expression begins with the first statement and proceeds through the statement list, typically until a jump statement, such as a `break`, `goto case`, `goto label`, `return`, or `throw`, is reached. At that point, control is transferred outside the `switch` statement or to another case label. A `goto` statement, if it is used, must transfer control to a constant label. This restriction is necessary, since attempting to transfer control to a non-constant label can have undesirable side-effects, such transferring control to an unintended location in code or creating an endless loop.
9898

9999
## Case labels
100100

0 commit comments

Comments
 (0)