[cfe-dev] should -Wimplicit-fallthrough require C++11?

David Blaikie dblaikie at gmail.com
Mon Nov 12 09:21:29 PST 2012


On Mon, Nov 12, 2012 at 9:08 AM, Douglas Gregor <dgregor at apple.com> wrote:
>
> 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.
>>>>>
>>>>>
>>>>> Right.
>>>>>
>>>>> I
>>>>> 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.

For my 2c: This warning was only added because we had a way to
annotate. In contexts where there is no such annotation the warning
doesn't really meet Clang's bar. Rather than forcing people to turn
this warning off depending on what they are compiling I think it makes
sense for it to be a no-op in any language variant where we don't
currently have an annotation mechanism.

(this means, imho, for the 3.2 release, we should do as Ted started &
have this disabled in both C and C++98 - unless someone's going to
whip up the annotation device necessary for those languages in very
short order (yes, I realize we've still got weeks until 3.2 actually
releases, but I don't see sufficient benefit to rushing through such a
change))

- David



More information about the cfe-dev mailing list