public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Add -Wshadow=local
@ 2018-09-23  4:08 Tom Tromey
  2018-09-23  4:08 ` [PATCH 3/8] Use std::string in mdebugread.c Tom Tromey
                   ` (9 more replies)
  0 siblings, 10 replies; 30+ messages in thread
From: Tom Tromey @ 2018-09-23  4:08 UTC (permalink / raw)
  To: gdb-patches

This series enables -Wshadow=local for gdb.

I think that shadowing is mildly confusing, and I normally try to
avoid it.  However, for a long time, it wasn't feasible to enable any
shadowing warnings, because gcc would warn about shadowing that was
"uninteresting" -- the classic example being the use of a local
variable named "index".

In this series I chose to use -Wshadow=local, to forbid shadowing
within a function.  -Wshadow=compatible-local is another choice, but I
think that the stated semantics:

    In C++, type compatibility here means the type of the shadowing
    variable can be converted to that of the shadowed variable.

... is maybe insufficient.  For example a situation where the two
different types are both convertible to a third type could be enough
to cause a bug.  That's a bit of a reach maybe, but it seemed to me
that it's not such a big deal, and certainly always safer, to just
disallow shadowing entirely.

Adding this warning found a few latent bugs in gdb.

Regression tested by the buildbot.  Thanks, Sergio, for your work
running this -- it is a great service.

Let me know what you think.  I feel that a change like this should
involve some feedback.

Tom


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2018-10-12  5:25 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-23  4:08 [PATCH 0/8] Add -Wshadow=local Tom Tromey
2018-09-23  4:08 ` [PATCH 3/8] Use std::string in mdebugread.c Tom Tromey
2018-10-12  4:27   ` Kevin Buettner
2018-09-23  4:08 ` [PATCH 5/8] Fix latent bug in msp430-tdep.c Tom Tromey
2018-10-12  4:10   ` Kevin Buettner
2018-09-23  4:08 ` [PATCH 8/8] Add -Wshadow=local Tom Tromey
2018-09-23  4:08 ` [PATCH 2/8] Avoid shadowing in gdbserver Tom Tromey
2018-10-12  4:19   ` Kevin Buettner
2018-09-23  4:08 ` [PATCH 4/8] Avoid shadowing in linux-tdep.c Tom Tromey
2018-10-12  4:50   ` Kevin Buettner
2018-09-23  4:08 ` [PATCH 6/8] Avoid shadowing in fdwalk Tom Tromey
2018-10-12  4:54   ` Kevin Buettner
2018-09-23  4:08 ` [PATCH 7/8] Shadowing fix in gdbscm_frame_read_var Tom Tromey
2018-10-03 16:12   ` Simon Marchi
2018-10-04 12:44     ` Tom Tromey
2018-09-23  4:09 ` [PATCH 1/8] Simple -Wshadow=local fixes Tom Tromey
2018-10-03 16:01   ` Simon Marchi
2018-10-04  3:36   ` Simon Marchi
2018-10-04 12:22     ` Simon Marchi
2018-10-04 12:43       ` Tom Tromey
2018-10-03 15:02 ` [PATCH 0/8] Add -Wshadow=local Simon Marchi
2018-10-03 16:16   ` Simon Marchi
2018-10-03 16:34     ` Pedro Alves
2018-10-03 17:53       ` Joel Brobecker
2018-10-05  4:57         ` Tom Tromey
2018-10-05  9:06           ` Rainer Orth
2018-10-05 11:14             ` Joel Brobecker
2018-10-05 13:37             ` [SPAM] " Tom Tromey
2018-10-05 15:58               ` Rainer Orth
2018-10-12  5:25 ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).