softwareQinc / staq

Full-stack quantum processing toolkit
https://iopscience.iop.org/article/10.1088/2058-9565/ab9359/pdf
MIT License
154 stars 28 forks source link

Some C++17 compilers cannot compile these two lines. #2

Closed DevelopDaily closed 4 years ago

DevelopDaily commented 4 years ago

https://github.com/softwareQinc/staq/blob/bc9caf8acca0cc6e7394547e4125ff7ecf06eb26/libs/sparsepp/spp_utils.h#L373

https://github.com/softwareQinc/staq/blob/bc9caf8acca0cc6e7394547e4125ff7ecf06eb26/libs/sparsepp/spp_utils.h#L378

I have to cast the type (uint32_t) to the argument explicitly just to make my compiler happy. I did that without intellectual rigor:-)

Could you please take a look at the issue?

Thanks.

vsoftco commented 4 years ago

Can you please specify which compiler (version) you're using? And you mean casting the return? Or v?

DevelopDaily commented 4 years ago

clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin

This is what I do:

return s_spp_popcount_default( (uint32_t) (v & -(intptr_t)v) - 1) );

return s_spp_popcount_default( (uint32_t) v);

Please note the compiler can work around the implicit casting by setting some compiler switches. But, I think it is perhaps better to do it explicitly just to avoid any subtle ambiguity.

vsoftco commented 4 years ago

@DevelopDaily Fixed in the latest release