kaldi-asr / kaldi

kaldi-asr/kaldi is the official location of the Kaldi project.
http://kaldi-asr.org
Other
14.28k stars 5.32k forks source link

Implicit fallthroughs #4929

Open r-barnes opened 3 months ago

r-barnes commented 3 months ago

Are these implicit fallthroughs intentional? If so, can we mark them with [[fallthrough]]?

https://github.com/kaldi-asr/kaldi/blob/122a3f239ed2f24271eb61b9aa3060fa06b820ac/src/nnet/nnet-convolutional-component.h#L157

https://github.com/kaldi-asr/kaldi/blob/122a3f239ed2f24271eb61b9aa3060fa06b820ac/src/nnet/nnet-sentence-averaging-component.h#L100

kkm000 commented 2 months ago

Yes. In both cases, we've just read the closing token <!EndOfComponent> and are falling through the default case, or didn't read any tokens at all, and breaking the loop at the first iteration.

[[fallthrough]] would be nice indeed. I guess the C++17 compiler yells at you? A C++14-compatible alternative is to repeat end_loop = true; and have the case end with the break;

@jtrmal, @danpovey, we are C++17 by default now, ain't we? No longer C++14? I can't think of a compiler that wouldn't C++17 these days.