Boost C++ Libraries: Ticket #8405: VC++ 2012 compiler warning C4189: '...' : local variable is initialized but not referenced https://svn.boost.org/trac10/ticket/8405 <p> I'm using Microsoft Visual Studio 2012 to compile boost 1.52.0. I use compiler flag /W4. The following warnings (which we declared errors for our project) occur in geometry, regardless whether I'm compiling for x64 or x86: </p> <pre class="wiki">\boost_1_52_0\boost\geometry\algorithms\detail\overlay\get_turns.hpp(140): error C4189: 'n' : local variable is initialized but not referenced int const n = int(section.range_count); </pre><pre class="wiki">\boost_1_52_0\boost\geometry\strategies\cartesian\distance_projected_point.hpp(161): error C4189: 'fp_strategy' : local variable is initialized but not referenced fp_strategy_type fp_strategy = strategy::distance::services::get_similar &lt; Strategy, Point, fp_point_type &gt;::apply(strategy); </pre><p> Maybe it's possible to eliminate these warnings for the next boost version? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8405 Trac 1.4.3 Barend Gehrels Fri, 05 Apr 2013 20:55:54 GMT type, severity changed https://svn.boost.org/trac10/ticket/8405#comment:1 https://svn.boost.org/trac10/ticket/8405#comment:1 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Support Requests</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Not Applicable</span> </li> </ul> <p> The code is: </p> <blockquote> <p> int const n = int(section.range_count); return boost::is_same </p> <blockquote> <p> &lt; </p> <blockquote> <p> typename tag_cast </p> <blockquote> <p> &lt; </p> <blockquote> <p> typename geometry::point_type&lt;Geometry1&gt;::type, areal_tag </p> <blockquote class="citation"> <p> ::type, </p> </blockquote> </blockquote> </blockquote> <p> areal_tag </p> <blockquote class="citation"> <p> ::value </p> </blockquote> </blockquote> </blockquote> <p> &amp;&amp; index1 == 0 &amp;&amp; index2 &gt;= n - 2 </p> <blockquote> <p> ; </p> </blockquote> </blockquote> <p> As you can see the variable n <strong>is</strong> referenced. </p> <p> However, if is_same returns false, the variable is (at compiletime) indeed not referenced. </p> <p> This can be solved by using another (and more complex) construction, not by just removing n. </p> <p> This has currently no priority. </p> <p> The advice is to check with /W3. </p> <p> The same for fp_strategy, this strategy <strong>is</strong> used, be it sometimes only the static functions, but that is not known at that specific location. </p> <p> I change the classification from "Bug" to "Support Request" </p> Ticket Barend Gehrels Fri, 05 Apr 2013 21:13:07 GMT severity changed https://svn.boost.org/trac10/ticket/8405#comment:2 https://svn.boost.org/trac10/ticket/8405#comment:2 <ul> <li><strong>severity</strong> <span class="trac-field-old">Not Applicable</span> → <span class="trac-field-new">Cosmetic</span> </li> </ul> Ticket Volker Schöch <vschoech@…> Sat, 06 Apr 2013 15:26:08 GMT <link>https://svn.boost.org/trac10/ticket/8405#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8405#comment:3</guid> <description> <p> Thank you for looking into this. I have no issue with the code as it is. However, I do have an issue with the warning being triggered. If you know that the warning is triggered even though the code is fine, why not locally suppress the warning with <code>#pragma warning(disable:4189)</code>? </p> <p> Compiling with /W3 is not an option for me; I will continue to suppress this warning specifically for boost::geometry. That's not a practical problem, I just think suppressing it locally in your code, with an appropriate comment, would be a better solution. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Sat, 06 Apr 2013 18:51:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8405#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8405#comment:4</guid> <description> <p> Yes, disabling might be an option. However, we get the chance then that gcc or clang still complain (did not check). </p> <p> Another option is adding boost::ignore_unused_variable_warning(n); that is quite easy to do ;-) This is valid for all compilers, and is not taking runtime. I did that earlier for some strategies, so it can also be done for fp_strategy. </p> <p> This might be done for most (but probably not all) your reported warning problems. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Sat, 06 Apr 2013 18:52:48 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8405#comment:5 https://svn.boost.org/trac10/ticket/8405#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> Ticket Barend Gehrels Sat, 06 Apr 2013 21:35:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8405#comment:6 https://svn.boost.org/trac10/ticket/8405#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket