Modify

Opened 8 years ago

Closed 8 years ago

#3603 closed Bugs (fixed)

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 (4)

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

Download all attachments as: .zip

Change History (14)

Changed 8 years ago by s.ochsenknecht@…

Attachment: fix_warnings.patch added

patch

comment:1 Changed 8 years ago by Vladimir Prus

(In [57535]) Fix warnings.

Addresses #3603. Patch from Sascha Ochsenknecht.

comment:2 Changed 8 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 8 years ago by mloskot <mateusz@…>

Cc: mateusz@… added

Changed 8 years ago by s.ochsenknecht@…

Attachment: any_cast_warning.patch added

patch

comment:4 Changed 8 years ago by anonymous

Type: PatchesBugs

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 8 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 8 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 8 years ago by anonymous

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

Changed 8 years ago by Sascha Ochsenknecht

Attachment: any_cast_warning.2.patch added

patch

Changed 8 years ago by Sascha Ochsenknecht

Attachment: any_warning.cpp added

test case

comment:8 Changed 8 years ago by Sascha 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 8 years ago by Sascha 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 8 years ago by Sascha Ochsenknecht

Milestone: Boost 1.41.0Boost 1.42.0
Resolution: fixed
Status: newclosed

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)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Vladimir Prus.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.