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

reinterpret_cast should maybe be static_cast #76

Open
adamnovak opened this issue Aug 24, 2020 · 1 comment
Open

reinterpret_cast should maybe be static_cast #76

adamnovak opened this issue Aug 24, 2020 · 1 comment

Comments

@adamnovak
Copy link
Member

Mac Clang is complaining we don't know how to cast right:


src/path_position_overlays.cpp:431:16: warning: 'reinterpret_cast' to class 'handlegraph::MutablePathDeletableHandleGraph *' from its virtual base 'handlegraph::PathHandleGraph *' behaves differently from 'static_cast' [-Wreinterpret-base-class]
        return reinterpret_cast<MutablePathDeletableHandleGraph*>(graph);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/path_position_overlays.cpp:431:16: note: use 'static_cast' to adjust the pointer correctly while downcasting
        return reinterpret_cast<MutablePathDeletableHandleGraph*>(graph);
               ^~~~~~~~~~~~~~~~
               static_cast

We could get into trouble with pointer offsets depending on how any given compiler is doing virtual base classes.

@jeizenga
Copy link
Contributor

There's also the option of storing the pointer twice with different properties: once in the mutable subclass and once in the immutable parent class.

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