Boost C++ Libraries: Ticket #3603: Fix warnings when compiling test cases https://svn.boost.org/trac10/ticket/3603 <p> I attached a patch which fixes some compile warnings on: </p> <pre class="wiki">Linux Trudheim 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux g++ (Ubuntu 4.4.1-4ubuntu8) 4.4.1 bjam gcc warnings=all cxxflags=-Wextra </pre><p> I still get a warning, but this one comes from another boost header: </p> <pre class="wiki">../../../boost/integer.hpp:145:24: warning: use of C99 long long integer constant </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3603 Trac 1.4.3 s.ochsenknecht@… Tue, 10 Nov 2009 06:54:07 GMT attachment set https://svn.boost.org/trac10/ticket/3603 https://svn.boost.org/trac10/ticket/3603 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fix_warnings.patch</span> </li> </ul> <p> patch </p> Ticket Vladimir Prus Tue, 10 Nov 2009 06:59:59 GMT <link>https://svn.boost.org/trac10/ticket/3603#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3603#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/57535" title="Fix warnings. Addresses #3603. Patch from Sascha Ochsenknecht. ">[57535]</a>) Fix warnings. </p> <p> Addresses <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3603" title="#3603: Bugs: Fix warnings when compiling test cases (closed: fixed)">#3603</a>. Patch from Sascha Ochsenknecht. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Vladimir Prus</dc:creator> <pubDate>Tue, 10 Nov 2009 07:03:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3603#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3603#comment:2</guid> <description> <p> Sascha, I have checked in this patch. I'll leave the issue open until the warnings from integer is resolved somehow -- and I'm posting an email about that. </p> </description> <category>Ticket</category> </item> <item> <author>mloskot <mateusz@…></author> <pubDate>Tue, 10 Nov 2009 10:13:59 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/3603#comment:3 https://svn.boost.org/trac10/ticket/3603#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">mateusz@…</span> added </li> </ul> Ticket s.ochsenknecht@… Tue, 10 Nov 2009 13:46:16 GMT attachment set https://svn.boost.org/trac10/ticket/3603 https://svn.boost.org/trac10/ticket/3603 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">any_cast_warning.patch</span> </li> </ul> <p> patch </p> Ticket anonymous Tue, 10 Nov 2009 13:56:29 GMT type changed https://svn.boost.org/trac10/ticket/3603#comment:4 https://svn.boost.org/trac10/ticket/3603#comment:4 <ul> <li><strong>type</strong> <span class="trac-field-old">Patches</span> → <span class="trac-field-new">Bugs</span> </li> </ul> <p> I got some other warnings when compiling options_description_test.cpp: </p> <pre class="wiki">../../../boost/any.hpp: In member function ‘void boost::program_options::typed_value&lt;T, charT&gt;::notify(const boost::any&amp;) const [with T = double, charT = char]’: options_description_test.cpp:182: instantiated from here ../../../boost/any.hpp:216: warning: type qualifiers ignored on function return type ../../../boost/any.hpp: In member function ‘void boost::program_options::typed_value&lt;T, charT&gt;::notify(const boost::any&amp;) const [with T = int, charT = char]’: options_description_test.cpp:182: instantiated from here ../../../boost/any.hpp:216: warning: type qualifiers ignored on function return type </pre><p> Probably these warnings point to a real bug (changed type to "bug" until it is clear). </p> <p> I compiled "by-hand" with: </p> <pre class="wiki">g++ options_description_test.cpp \ -g -Wall -Wextra -pedantic -I../../.. -L/my/private/libdir -lboost_program_options -o a.out </pre><p> I'm not quite sure, but I think any_cast is used in a wrong way. I added any_cast_warning.patch which should solve this problem ... but please review! </p> <p> Thanks </p> Ticket Vladimir Prus Wed, 18 Nov 2009 16:43:20 GMT <link>https://svn.boost.org/trac10/ticket/3603#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3603#comment:5</guid> <description> <p> options_description_test.cpp does not even have line 182 in my copy. And I don't get the warning either. So, how do I reproduce this? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Vladimir Prus</dc:creator> <pubDate>Wed, 18 Nov 2009 16:49:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3603#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3603#comment:6</guid> <description> <p> Hmm, the any_cast that reports the error is the one taking reference to any, while The code in typed_value::notify is supposed to call the one taking pointer. I am completely confused. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 18 Nov 2009 18:59:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3603#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3603#comment:7</guid> <description> <p> Looking deeper to it, confuses me also :-(. Will comment on that asap. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sascha Ochsenknecht</dc:creator> <pubDate>Thu, 19 Nov 2009 07:25:23 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/3603 https://svn.boost.org/trac10/ticket/3603 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">any_cast_warning.2.patch</span> </li> </ul> <p> patch </p> Ticket Sascha Ochsenknecht Thu, 19 Nov 2009 07:26:25 GMT attachment set https://svn.boost.org/trac10/ticket/3603 https://svn.boost.org/trac10/ticket/3603 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">any_warning.cpp</span> </li> </ul> <p> test case </p> Ticket Sascha Ochsenknecht Thu, 19 Nov 2009 07:28:12 GMT <link>https://svn.boost.org/trac10/ticket/3603#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3603#comment:8</guid> <description> <p> I guess I found the problem, my first approach was due to misunderstanding. Sorry for confusion. </p> <p> Here is what the gcc manual says about this warning: </p> <pre class="wiki">Warn if the return type of a function has a type qualifier such as const. For ISO C such a type qualifier has no effect, since the value returned by a function is not an lvalue. </pre><p> So, the any cast is supposed to return "const T* const" due to the template parameter &lt;const T&gt;. Here is declaration of the any_cast: </p> <pre class="wiki">template&lt;typename ValueType&gt; const ValueType * any_cast(const any * operand); </pre><p> So, the line in detail/value_semantic.hpp has to be changed from: </p> <pre class="wiki">const T* value = boost::any_cast&lt;const T&gt;(&amp;value_store); </pre><p> to </p> <pre class="wiki">const T* value = boost::any_cast&lt;T&gt;(&amp;value_store); </pre><p> I attached a new any_cast_warning.2.patch and a test case any_warning.cpp </p> <p> Cheers, Sascha </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sascha Ochsenknecht</dc:creator> <pubDate>Fri, 20 Nov 2009 16:00:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3603#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3603#comment:9</guid> <description> <p> The any_cast issue is resolved, see <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2562" title="#2562: Bugs: warning: type qualifiers ignored on function return type (closed: fixed)">#2562</a> </p> <p> This ticket is still open due to the integer issue which is still not resolved. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sascha Ochsenknecht</dc:creator> <pubDate>Thu, 03 Dec 2009 17:58:22 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/3603#comment:10 https://svn.boost.org/trac10/ticket/3603#comment:10 <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> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.41.0</span> → <span class="trac-field-new">Boost 1.42.0</span> </li> </ul> <p> The integer issue seems to be resolved on trunk, so I close the ticket. I could not see any warning currently (using <code>bjam gcc warnings=all cxxflags=-Wextra</code>) </p> Ticket