[cfe-dev] -Warray-bounds seems over-zealous on Clang
peter at 2ndquadrant.com
Wed Jul 13 02:13:29 PDT 2011
On 13 July 2011 01:06, Nico Weber <thakis at chromium.org> wrote:
> In the past, warnings that warns about a common pattern but also find
> bugs have been kept on-by-default. Search this list for
I don't have time to review Clang's exact behavior there right now,
but my guess is that this is a false equivalency. Code that causes
that warning at the class definition (which I think is what you allude
to - no delete is required) is inherently wrong according to the C++
intelligentsia, unless the base dtor is declared protected per an
idiom described by Herb Sutter. No one would ever encourage virtual
functions with a non-virtual public dtor (some styleguides go so far
as to require all dtors be virtual, which even the std lib violates),
whereas what I describe is in various text books.
> This bug is in ICU, which is pretty commonly used. Someone (me) posted
> an example where this warning found a bug within 2h of Chris asking
> for it, so maybe it's not as vanishingly small as you think.
That bug was really obvious, and was a narrow case of someone misusing
a struct that used this idiom. I doubt the developer of that app would
thank you for your attitude - you just saved them this one bug, but
you probably created a whole bunch of spurious warnings at other parts
of their codebase in the process. Why should they even think that it's
valid in this one place anyway, where it is only valid by dumb luck?
They weren't clued-in enough to catch a really obvious bug in the
On 13 July 2011 04:39, Chris Lattner <clattner at apple.com> wrote:
> -Warray-bounds-single-element seems like overkill to me, but is completely feasible.
Right. Let the extremely paranoid individuals (avionics engineers,
medical equipment engineers) throw every single flag that produces
additional warnings at Clang, which they're quite happy to do their
homework on. Let the vast majority of developers have sane,
non-annoying behaviour without any burden to pass additional flags.
Peter Geoghegan http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services
More information about the cfe-dev