Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost 1.54.0 Header Warnings: Shadowed Variables
From: Tom Browder (tom.browder_at_[hidden])
Date: 2013-11-13 07:08:52


On Wed, Nov 13, 2013 at 5:41 AM, Tom Browder <tom.browder_at_[hidden]> wrote:
> On Tue, Nov 12, 2013 at 8:20 PM, Edward Diener <eldiener_at_[hidden]> wrote:
>> On 11/12/2013 7:03 PM, Tom Browder wrote:
>>> On Sat, Nov 9, 2013 at 7:08 AM, Tom Browder <tom.browder_at_[hidden]> wrote:
>>>> On Sat, Nov 9, 2013 at 6:46 AM, John Maddock <john_at_[hidden]>
>>>> wrote:
>>>>> I suggest you file bug reports regarding any problems
>>>>> you find: if the fix is trivial and they come with patches even better.

Here is a snippet from Carnegie Mellon's CERT C++ Secure Coding Standard site:

  https://www.securecoding.cert.org/confluence/display/cplusplus/DCL01-CPP.+Do+not+reuse+variable+names+in+subscopes

which describes more than one of the shadowed-variable situations:

<quote>
Do not use the same variable name in two scopes where one scope is
contained in another. For example

+ No other variable should share the name of a global variable if the
other value is in a subscope of the global variable.

+ A block should not declare a variable with the same name as a
variable declared in any block that contains it.

Reusing variable names leads to programmer confusion about which
variable is being modified. Additionally, if variable names are
reused, generally one or both of the variable names are too generic.
</quote>

I worry about the possible misunderstanding of the authors of such code.

Best regards,

-Tom


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net