Modify

Ticket #3603 (closed Bugs: fixed)

Opened 4 years ago

Last modified 4 years ago

Fix warnings when compiling test cases

Reported by: s.ochsenknecht@… Owned by: vladimir_prus
Milestone: Boost 1.42.0 Component: program_options
Version: Boost 1.40.0 Severity: Cosmetic
Keywords: Cc: mateusz@…

Description

I attached a patch which fixes some compile warnings on:

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

I still get a warning, but this one comes from another boost header:

../../../boost/integer.hpp:145:24: warning: use of C99 long long integer constant

Attachments

fix_warnings.patch Download (13.3 KB) - added by s.ochsenknecht@… 4 years ago.
patch
any_cast_warning.patch Download (575 bytes) - added by s.ochsenknecht@… 4 years ago.
patch
any_cast_warning.2.patch Download (566 bytes) - added by s_ochsenknecht 4 years ago.
patch
any_warning.cpp Download (378 bytes) - added by s_ochsenknecht 4 years ago.
test case

Change History

Changed 4 years ago by s.ochsenknecht@…

patch

comment:1 Changed 4 years ago by vladimir_prus

(In [57535]) Fix warnings.

Addresses #3603. Patch from Sascha Ochsenknecht.

comment:2 Changed 4 years ago by vladimir_prus

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.

comment:3 Changed 4 years ago by mloskot <mateusz@…>

  • Cc mateusz@… added

Changed 4 years ago by s.ochsenknecht@…

patch

comment:4 Changed 4 years ago by anonymous

  • Type changed from Patches to Bugs

I got some other warnings when compiling options_description_test.cpp:

../../../boost/any.hpp: In member function ‘void boost::program_options::typed_value<T, charT>::notify(const boost::any&) 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<T, charT>::notify(const boost::any&) 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

Probably these warnings point to a real bug (changed type to "bug" until it is clear).

I compiled "by-hand" with:

g++ options_description_test.cpp \
   -g -Wall -Wextra -pedantic -I../../.. -L/my/private/libdir -lboost_program_options -o a.out 

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!

Thanks

comment:5 Changed 4 years ago by vladimir_prus

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?

comment:6 Changed 4 years ago by vladimir_prus

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.

comment:7 Changed 4 years ago by anonymous

Looking deeper to it, confuses me also :-(. Will comment on that asap.

Changed 4 years ago by s_ochsenknecht

patch

Changed 4 years ago by s_ochsenknecht

test case

comment:8 Changed 4 years ago by s_ochsenknecht

I guess I found the problem, my first approach was due to misunderstanding. Sorry for confusion.

Here is what the gcc manual says about this warning:

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.

So, the any cast is supposed to return "const T* const" due to the template parameter <const T>. Here is declaration of the any_cast:

template<typename ValueType> const ValueType * any_cast(const any * operand);

So, the line in detail/value_semantic.hpp has to be changed from:

const T* value = boost::any_cast<const T>(&value_store);

to

const T* value = boost::any_cast<T>(&value_store);

I attached a new any_cast_warning.2.patch and a test case any_warning.cpp

Cheers, Sascha

comment:9 Changed 4 years ago by s_ochsenknecht

The any_cast issue is resolved, see #2562

This ticket is still open due to the integer issue which is still not resolved.

comment:10 Changed 4 years ago by s_ochsenknecht

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from Boost 1.41.0 to Boost 1.42.0

The integer issue seems to be resolved on trunk, so I close the ticket. I could not see any warning currently (using bjam gcc warnings=all cxxflags=-Wextra)

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.