Opened 9 years ago
Last modified 9 years ago
#8694 new Bugs
gcc -Wcast-qual warning in boost/function/function_template.hpp
Reported by: | Owned by: | Douglas Gregor | |
---|---|---|---|
Milestone: | To Be Determined | Component: | function |
Version: | Boost 1.53.0 | Severity: | Cosmetic |
Keywords: | Cc: |
Description
When using boost function library with -Wcast-qual and -Werror flags enabled the following error comes up boost/function/function_template.hpp:628:35 error: cast from type 'const ...*' to type 'void*' casts away qualifiers [-Werror=cast-qual] functor.obj_ref.obj_ptr = (void *)(f.get_pointer()); .....
This warning happens when f.get_pointer() is a const pointer (e.g. it is originating from boost::cref). Which leads to this C-style cast that casts away of constness. I think this can be fixed by replacing C-style cast by const_cast<void*>(static_cast<const void*>(f.get_pointer())) or by adding GCC pragmas to disable -Wcast-qual warning in this header file.
Please could you check if you suggestion work and send a patch or do a pull request?