[cfe-dev] should -Wimplicit-fallthrough require C++11?
dgregor at apple.com
Mon Nov 12 09:08:28 PST 2012
On Nov 12, 2012, at 9:05 AM, Jordan Rose <jordan_rose at apple.com> wrote:
> On Nov 12, 2012, at 6:35 , Douglas Gregor <dgregor at apple.com> wrote:
>> On Nov 10, 2012, at 10:41 AM, Nico Weber <thakis at chromium.org> wrote:
>>> On Fri, Nov 9, 2012 at 8:15 PM, Ted Kremenek <kremenek at apple.com> wrote:
>>>> On Nov 9, 2012, at 7:04 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>>>> The original intention was that the warning could be used in any
>>>> language mode, if you wanted a warning on *all* switch fallthrough,
>>>> and that people who didn't want that could just not turn it on.
>>>> guess the complaints you're receiving are for situations where the
>>>> warning can't simply be disabled (or not enabled in the first place)?
>>>> What has happened is that a fair number of users have discovered this
>>>> warning using -Weverything. When they first discover it they find it
>>>> interesting. After they discover that they cannot add an annotation (as the
>>>> warning suggests) they get very frustrated. They are then left with the
>>>> choice of just turning the warning off, or using pragmas. For those users
>>>> who like the warning in principle, but find that they cannot use it in
>>>> practice because of these limitations (because they are not using C++11)
>>>> they view it is an incomplete feature. Several people have thus requested
>>>> to not see the warning at all.
>>> If you're using -Weverything, shouldn't the expectation be that you'll
>>> end up turning off several warnings?
>> Yes, but only if those warnings aren't useful to your situation. This warning should have widespread applicability, but it's actually useless outside of C++11 because there's no clean workaround.
> I disagree; as a stylistic warning -Wimplicit-fallthrough is still useful. I can definitely see a project where you'd prefer to disallow all fallthroughs and require copied code rather than annotating with a comment.
I can certainly imagine someone coming up with this rule, but I can't imagine myself ever agreeing that it's the right thing to do :)
Copy-and-pasting code is not, in my opinion, a reasonable way to silence a warning. We need something better; __fallthrough would be fine by me.
More information about the cfe-dev