Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: dynamic_cast can never succeed #175

Open
kirichoi opened this issue Aug 31, 2017 · 2 comments
Open

warning: dynamic_cast can never succeed #175

kirichoi opened this issue Aug 31, 2017 · 2 comments

Comments

@kirichoi
Copy link

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 SynBioDex/pySBOL#39 but we need to inspect the code because this can be a serious issue.

@bbartley
Copy link
Contributor

bbartley commented Sep 8, 2017

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

@kirichoi
Copy link
Author

kirichoi commented Sep 8, 2017

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.

@kirichoi kirichoi removed the Priority label Sep 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants