Menu

#144 Redefining parameter variable with a local one with the same name

Feature Request
closed-fixed
nobody
5
2016-10-26
2016-09-27
vstrinski
No

While running log4cpp-1.1.2rc3 through a static code analyzer (required for our company) I got a possible defect that is likely not a bug but can surprise the less careful:

in Properties.cpp the parmeter value gets hidden by another variable with the same name (lines 111 and 138)

111: void Properties::_substituteVariables(std::string& value) { ... 138: char* value = std::getenv(key.c_str());

Looking at the compiled assembly code it appeared that my compiler did the right thing, but some compilers might not be as nice.

And thanks again to all developers for their outstanding work! :)

Regards,
V

1 Attachments

Discussion

  • Alexander Perepelkin

    Thanks for the report.
    The variable is hidden indeed, but the scope is realy small so the reader must understand it well; and compilers are required to handle that. However, the small change could be done )

     
  • Alexander Perepelkin

    • status: open --> closed-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.