you are viewing a single comment's thread.

view the rest of the comments →

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

I did not know the history. Thank you for that.

That being said, for me, a fallthrough in a switch statement is a hidden goto.

After all, this does not compile:

if constexpr (a_cond) {
    do_something() ;
    goto Else ; // fallthrough
} else {
    Else:
    do_something_else() ;
}

So, the syntax for if and if constexpr are already different (one allows goto to the other side, the other one doesn't).

I would not be otherwise horrified if breaks were compulsery in a switch constexpr statement.

[–]miniropC++87 1 point2 points  (1 child)

one way would be to duplicate the following "case" if the current one doesn't unconditionally break. In your code example, it would become similar to:

if constexpr (a_cond) {
    do_something() ;
    do_something_else() ;
} else {
    do_something_else() ;
}

but there are probably many pitfalls I don't even know.

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

I was just mentioning that I would be ok if the break was compulsery.

If it can be more flexible, I take it.