P
Preben
Hi
I'm having a strange problem here.
I can't get this working:
const rw::kinematics::Frame* f = static_cast<const
rw::kinematics::Frame*>(joints);
However this works with no problems:
const rw::kinematics::Frame* f = (rw::kinematics::Frame*) joints;
where "joints" are defined as
const std::vector<rw::models::Joint*>& joints = _serialDevice->getJoints();
In some cases the static_cast works, but in other cases it doesn't work.
I think it's a bug in the compiler, but you can maybe convince me
otherwise. In the class CRTPlanner I'm using the template class
ManipulatorKinematics in the initializer list. This seems to trigger the
problem. There doesn't seem to be problems in other situations. The
output of the compiler is given below:
--------------
/usr/bin/c++ -DRW_ENABLE_ASSERT -g3 -pipe -g
-I/home/preben/working/RobWork-0.5/RobWork/build/../ext
-I/home/preben/working/RobWork-0.5/RobWork/build/../src
-I/usr/include/boost-1_41
-I/home/preben/working/RobWork-0.5/RobWork/ext/yaobi
-I/home/preben/working/RobWork-0.5/RobWork/ext/PQP
-I/home/preben/working/CRTPlanner/src -save-temps -o
CMakeFiles/planning.dir/CRTPlanner.cpp.o -c
/home/preben/working/CRTPlanner/CRTPlanner.cpp
c++: warning: -pipe ignored because -save-temps specified
In file included from /home/preben/working/CRTPlanner/CRTPlanner.hpp:15,
from /home/preben/working/CRTPlanner/CRTPlanner.cpp:11:
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp: In member
function 'const std::vector<rw::math::Transform3D<Q>,
std::allocator<rw::math::Transform3D<Q> > >
rw::dynamics::ManipulatorKinematics<T>::worldTlink(const
rw::kinematics::State&) const [with T = double]':
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp:209:
instantiated from 'void
rw::dynamics::ManipulatorKinematics<T>::initialize() [with T = double]'
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp:38:
instantiated from
'rw::dynamics::ManipulatorKinematics<T>::ManipulatorKinematics(rw::models::SerialDevicePtr,
const rw::kinematics::State&) [with T = double]'
/home/preben/working/CRTPlanner/CRTPlanner.cpp:32: instantiated from here
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp:99: error:
invalid static_cast from type 'rw::models::Joint* const' to type 'const
rw::kinematics::Frame*'
/home/preben/working/CRTPlanner/MechComputer.hpp: At global scope:
/home/preben/working/CRTPlanner/MechComputer.hpp:76: warning: inline
function 'boost::numeric::ublas::vector<double,
I've used the -save-temps flag on the working copy (c-like casts) and
the non-working copy (c++ cast).
They can be found here:
http://jobc.dk/cpp/CRTPlanner.ii.working
http://jobc.dk/cpp/CRTPlanner.ii.notworking
http://jobc.dk/cpp/CRTPlanner.s.working
http://jobc.dk/cpp/CRTPlanner.s.notworking
The gcc-version is:
---------
preben@ul30vt ~/working/CRTPlanner/build/Debug $ g++ -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.4.3-r2/work/gcc-4.4.3/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.3
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --without-ppl --without-cloog --enable-nls
--without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --enable-multilib
--enable-libmudflap --disable-libssp --enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/python
--enable-java-awt=gtk --enable-languages=c,c++,java,fortran
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/
--with-pkgversion='Gentoo 4.4.3-r2 p1.2'
Thread model: posix
gcc version 4.4.3 (Gentoo 4.4.3-r2 p1.2)
I'm having a strange problem here.
I can't get this working:
const rw::kinematics::Frame* f = static_cast<const
rw::kinematics::Frame*>(joints);
However this works with no problems:
const rw::kinematics::Frame* f = (rw::kinematics::Frame*) joints;
where "joints" are defined as
const std::vector<rw::models::Joint*>& joints = _serialDevice->getJoints();
In some cases the static_cast works, but in other cases it doesn't work.
I think it's a bug in the compiler, but you can maybe convince me
otherwise. In the class CRTPlanner I'm using the template class
ManipulatorKinematics in the initializer list. This seems to trigger the
problem. There doesn't seem to be problems in other situations. The
output of the compiler is given below:
--------------
/usr/bin/c++ -DRW_ENABLE_ASSERT -g3 -pipe -g
-I/home/preben/working/RobWork-0.5/RobWork/build/../ext
-I/home/preben/working/RobWork-0.5/RobWork/build/../src
-I/usr/include/boost-1_41
-I/home/preben/working/RobWork-0.5/RobWork/ext/yaobi
-I/home/preben/working/RobWork-0.5/RobWork/ext/PQP
-I/home/preben/working/CRTPlanner/src -save-temps -o
CMakeFiles/planning.dir/CRTPlanner.cpp.o -c
/home/preben/working/CRTPlanner/CRTPlanner.cpp
c++: warning: -pipe ignored because -save-temps specified
In file included from /home/preben/working/CRTPlanner/CRTPlanner.hpp:15,
from /home/preben/working/CRTPlanner/CRTPlanner.cpp:11:
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp: In member
function 'const std::vector<rw::math::Transform3D<Q>,
std::allocator<rw::math::Transform3D<Q> > >
rw::dynamics::ManipulatorKinematics<T>::worldTlink(const
rw::kinematics::State&) const [with T = double]':
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp:209:
instantiated from 'void
rw::dynamics::ManipulatorKinematics<T>::initialize() [with T = double]'
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp:38:
instantiated from
'rw::dynamics::ManipulatorKinematics<T>::ManipulatorKinematics(rw::models::SerialDevicePtr,
const rw::kinematics::State&) [with T = double]'
/home/preben/working/CRTPlanner/CRTPlanner.cpp:32: instantiated from here
/home/preben/working/CRTPlanner/ManipulatorKinematics.hpp:99: error:
invalid static_cast from type 'rw::models::Joint* const' to type 'const
rw::kinematics::Frame*'
/home/preben/working/CRTPlanner/MechComputer.hpp: At global scope:
/home/preben/working/CRTPlanner/MechComputer.hpp:76: warning: inline
function 'boost::numeric::ublas::vector<double,
boost::numeric::ublas::vector<double,boost::numeric::ublas::unbounded_array said:> rw::dynamics::MechComputer::calcAcceleration(const
boost::numeric::ublas::unbounded_array said:>&, const boost::numeric::ublas::vector<double,
--------------boost::numeric::ublas::unbounded_array said:>&) const' used but never defined
I've used the -save-temps flag on the working copy (c-like casts) and
the non-working copy (c++ cast).
They can be found here:
http://jobc.dk/cpp/CRTPlanner.ii.working
http://jobc.dk/cpp/CRTPlanner.ii.notworking
http://jobc.dk/cpp/CRTPlanner.s.working
http://jobc.dk/cpp/CRTPlanner.s.notworking
The gcc-version is:
---------
preben@ul30vt ~/working/CRTPlanner/build/Debug $ g++ -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.4.3-r2/work/gcc-4.4.3/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.3
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --without-ppl --without-cloog --enable-nls
--without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --enable-multilib
--enable-libmudflap --disable-libssp --enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/python
--enable-java-awt=gtk --enable-languages=c,c++,java,fortran
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/
--with-pkgversion='Gentoo 4.4.3-r2 p1.2'
Thread model: posix
gcc version 4.4.3 (Gentoo 4.4.3-r2 p1.2)