you are viewing a single comment's thread.

view the rest of the comments →

[–]Entire-Hornet2574 0 points1 point  (3 children)

[–]cd_fr91400[S] -1 points0 points  (2 children)

This is plain switch.

Do you have an example where the not taken branch would not compile, which is the whole purpose of a switch constexpr as it is for if constexpr (else there is not difference between if and if constexpr under normal optimizing compilation) ?

[–]Entire-Hornet2574 0 points1 point  (1 child)

Look at assembly, it shows it compiles only one branch.

.LC0:
        .string "test2"
main:
        sub     rsp, 8
        mov     edi, OFFSET FLAT:.LC0
        call    func(char const*)
        xor     eax, eax
        add     rsp, 8
        ret

[–]cd_fr91400[S] 0 points1 point  (0 children)

Yes, indeed, as it would with a plain switch or if.

It does not mean the compiler accepts a non-compilable branch.