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

PluginFactoryBase::make_return problem with longs #875

Closed
andresailer opened this issue Oct 29, 2021 · 3 comments
Closed

PluginFactoryBase::make_return problem with longs #875

andresailer opened this issue Oct 29, 2021 · 3 comments
Assignees
Labels
Fixed Problem is solved Testing

Comments

@andresailer
Copy link
Member

namespace dd4hep {
template <> inline long PluginFactoryBase::make_return(const long& value)
{ static long stored=value; return (long)&stored; }
}

As long is only at least 32 bits, and I am using a 64 bit system, this casting to long is going to not allow one to retrieve the value of the long because the ptr address will be a bit random, right?
Instead return a long*?

@MarkusFrankATcernch
Copy link
Contributor

On all "reasonable" OSes, sizeof(long) == sizeof(void*).
A pointer always fits into a long, because in the OS kernel typically longs are used.....

@andresailer
Copy link
Member Author

OK true.
But then I don't understand why I still don't get the return value of my plugin and just 1 instead of 42.

@andresailer andresailer changed the title PluginFactoryBase::make_return problem with longs and 64 bit ptrs PluginFactoryBase::make_return problem with longs Oct 29, 2021
@andresailer andresailer self-assigned this Oct 29, 2021
@andresailer
Copy link
Member Author

Testing with the plugins in DD4hep, I get the correct result value out of the plugins. Doing this in key4hep/k4ActsTracking#3 which also includes Gaudi (maybe related) I always get back 1,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed Problem is solved Testing
Projects
None yet
Development

No branches or pull requests

2 participants