Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the compliant solution, by moving the statements before the first case statement outside the switch block, the execution can be ensured and result in an expected behavior.

Info
titleBe Careful
Wiki Markup

int func ( int expr )
{
	int i = 4;    // Move the code outside the switch block
	f(i);         // Now the statements will get executed

	switch (expr) {
	 case 0:
		i = 17;
		/*falls through into default code */
	default:	
		printf(“%d\n”, i);
	}
	return 0;
}