pothosware / PothosCore

The Pothos data-flow framework
https://github.com/pothosware/PothosCore/wiki
Boost Software License 1.0
302 stars 48 forks source link

Fixed bug were default constructor Pothos::PluginPath creating a shad… #166

Closed ashley-b closed 5 years ago

ashley-b commented 5 years ago

Subtle bug found during build

pothos/lib/Util/BlockDescription.cpp: In function ‘json parseCommentBlockForMarkup(const CodeBlock&)’:
pothos/lib/Util/BlockDescription.cpp:306:36: warning: unnecessary parentheses in declaration of ‘payload’ [-Wparentheses]
             try {Pothos::PluginPath(payload);}
                                    ^
pothos/lib/Util/BlockDescription.cpp:306:44: warning: declaration of ‘payload’ shadows a previous local [-Wshadow]
             try {Pothos::PluginPath(payload);}
                                            ^
pothos/lib/Util/BlockDescription.cpp:247:17: note: shadowed declaration is here
     std::string payload;
                 ^~~~~~~
pothos/lib/Util/BlockDescription.cpp:436:36: warning: unnecessary parentheses in declaration of ‘path’ [-Wparentheses]
             try {Pothos::PluginPath(path);}
                                    ^
pothos/lib/Util/BlockDescription.cpp:436:41: warning: declaration of ‘path’ shadows a previous local [-Wshadow]
             try {Pothos::PluginPath(path);}
                                         ^

Also I noticed https://github.com/pothosware/PothosCore/blob/4bb5aad9bdafb0424750a021e84d4d29d87da473/include/Pothos/Plugin/Path.hpp#L30 Not sure if this was to mitigate such problems, but far as I'm aware explicit on a default constructor has no effect.

guruofquality commented 5 years ago

Calling a constructor in C++ with parenthesis is basically an ambiguous syntax. I don't know whats wrong with this particular syntax. I am familiar with "C++'s most vexing parse" https://stackoverflow.com/questions/1424510/my-attempt-at-value-initialization-is-interpreted-as-a-function-declaration-and

Anyway, thanks; the C++11 curly braces do the trick. And also I dont see why the PluginPath is explicit, I will remove it.