swtv-kaist / cs458-spring24

7 stars 0 forks source link

[HW4] Part 4, handling `default`. #16

Closed leejy12 closed 5 months ago

leejy12 commented 6 months ago

I want some clarification regarding Note 3.

Note3. For a switch statement, your program should print out case and (implicit) default statements. 
A conditional expression of case statement is a corresponding case value and that of default is 
``default’’

Does this mean that kcov should print default regardless of if explicit default statement exists or not? For example,

01. switch (x) {
02.   case 1:
03.     break;
04.   default:
05.     break;
06. }
07. 
08. switch (y) {
09.   case 3:
10.     break;
11.   case 4:
12.     break;
13. }

will result in

Line taken else expr
2 ? ? 1
4 ? ? default
8 ? ? default
9 ? ? 3
11 ? ? 4

Is this correct?

3-24 commented 6 months ago

Yes, you are right. kcov should print both implicit and explicit defaults.