Skip to content

Nested switch break can cause EXCEPTION_ILLEGAL_INSTRUCTION #2479

Description

@m910q

Despite a nested break;, a switch is still considered to never break when they all return a value.
Causes EXCEPTION_ILLEGAL_INSTRUCTION in Debug and crashes in Release.
Tested in latest nightly.

class Program
{
	public static int Main(String[] args)
	{
        switch (0) {
            case 0:
                if (true) { break; }
                return 1;
            default:
                return 2;
        }
		return 0; // <-- "Unreachable code" warning in IDE
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions