SynBioDex / libSBOL

C++ implementation of SBOL 2.3.2
Apache License 2.0
15 stars 7 forks source link

warning: dynamic_cast can never succeed #175

Open kirichoi opened 7 years ago

kirichoi commented 7 years ago

When building Python bindings, series of warnings are produced, e.g.: warning: dynamic_cast of ‘sbol::Component dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed

This is probably tied to dummy code we added to mitigate issue https://github.com/SynBioDex/pySBOL/issues/39 but we need to inspect the code because this can be a serious issue.

bbartley commented 7 years ago

I don't get this warning using clang compiler. What file and line number generates the warning?

kirichoi commented 7 years ago

I see one file involved with this (document.h). Parts of output pasted below:

[ 58%] Building CXX object source/CMakeFiles/sbol64.dir/assembly.cpp.o
In file included from /home/kirichoi/Desktop/libSBOL/source/assembly.h:30:0,
                 from /home/kirichoi/Desktop/libSBOL/source/assembly.cpp:26:
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::Component; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/assembly.cpp:92:73:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::Component dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
             TopLevel* check_top_level = dynamic_cast<TopLevel*>(&dummy_obj);
                                                                           ^
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::FunctionalComponent; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/assembly.cpp:375:75:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::FunctionalComponent dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
                                                                                   ^
[ 91%] Building CXX object wrapper/CMakeFiles/_libsbol.dir/__/release/wrapper/libsbolPYTHON_wrap.cxx.o
In file included from /home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:3331:0:
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::Location; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::Location; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:53912:52:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::Location dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
             TopLevel* check_top_level = dynamic_cast<TopLevel*>(&dummy_obj);
                                                                           ^
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::MapsTo; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::MapsTo; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:59950:50:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::MapsTo dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::SequenceConstraint; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::SequenceConstraint; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:65988:62:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::SequenceConstraint dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::SequenceAnnotation; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::SequenceAnnotation; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:72026:62:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::SequenceAnnotation dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::Component; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::Component; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:78064:53:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::Component dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::Participation; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::Participation; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:84301:57:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::Participation dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::Module; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::Module; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:90339:50:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::Module dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::Interaction; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::Interaction; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:96377:55:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::Interaction dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed
/home/kirichoi/Desktop/libSBOL/source/document.h: In instantiation of ‘SBOLClass& sbol::OwnedObject<SBOLClass>::operator[](std::__cxx11::string) [with SBOLClass = sbol::FunctionalComponent; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/kirichoi/Desktop/libSBOL/source/document.h:626:50:   required from ‘SBOLClass& sbol::OwnedObject<SBOLClass>::get(std::__cxx11::string) [with SBOLClass = sbol::FunctionalComponent; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/kirichoi/Desktop/libSBOL/release/wrapper/libsbolPYTHON_wrap.cxx:102415:63:   required from here
/home/kirichoi/Desktop/libSBOL/source/document.h:680:75: warning: dynamic_cast of ‘sbol::FunctionalComponent dummy_obj’ to ‘class sbol::TopLevel*’ can never succeed

If it's fine in clang I won't worry too much about it but it might be nice to fix this so that gcc does not output large block of warning.