Re: [PATCH 18/348] Fix -Wsahdow warnings

Eli Zaretskii
2011-11-25T12:03:49Z

> Date: Thu, 24 Nov 2011 14:00:57 -0800
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches <gdb-patches@sourceware.org>
>
> I mean, I understand that "index" might be part of a system's
> include. But "block_found" (or was it "found_block") seems quite
> surprising.

If it surprised you, it means -Wsahdow did its job well.

IOW, it's easy to avoid well-known names like `printf' or `strchr'.
It's the not-so-well-known names that give you hell and high water.

> Add the fact that includes and compiler vary from system to system,
> and we're not sure that once clean on one machine, it'll be clean
> everywhere else.

But this is true of any other non-trivial piece of our code. E.g., if
you declare a variable `long' expecting it to be a 64-bit type, this
will break on MS-Windows, and you will never no until you actually try
such a compilation.

In general, we have no bullet-proof way of making sure our code works
on all supported platforms, except by actually compiling it on those
platforms. That's why platforms which lose their area maintainers
bit-rot quite quickly. This compiler switch doesn't change this
situation in any way.

> All of this to fix warnings that, as far as I could tell for the
> most part, did not indicate an actual bug in the code.

It's a bug waiting to happen, though. That it didn't happen yet is
just sheer luck.