simongog / sdsl-lite

Succinct Data Structure Library 2.0
Other
2.21k stars 350 forks source link

coder_comma.hpp initialization of codelentbllen exercises OS X c++ compiler bug #224

Closed KellyJDavis closed 9 years ago

KellyJDavis commented 9 years ago

Thanks for the quick fix on coder_comma.hpp!

However, the fix exercises a bug in the OS X 10.10.2 c++ compiler "Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)."

Upon running the install.sh script one encounters the following error...

...
<InstallPath>/sdsl-lite/sdsl-lite/build/lib/../include/sdsl/coder_comma.hpp:76:45: error: use of default argument to function 'base_fits_in_64' that is declared later in class 'comma'
        static const size_t codelentbllen = base_fits_in_64(base);
                                            ^
<InstallPath>/sdsl-lite/sdsl-lite/build/lib/../include/sdsl/coder_comma.hpp:65:81: note: default argument declared here
        static constexpr size_t base_fits_in_64(uint32_t base, uint64_t product=0xFFFFFFFFFFFFFFFFULL, size_t res=0)
                                                                                ^

This seems like a compiler bug as opposed to a bug in coder_comma.hpp.

I can cut a quick branch and put some code in that works around the bug in the compiler.

Doesn't look like I have permissions to cut a branch. But, a quick fix seem to be

--- a/include/sdsl/coder_comma.hpp
+++ b/include/sdsl/coder_comma.hpp
@@ -62,7 +62,7 @@ class comma
         static_assert(t_width > 1 && t_width <= 32,
                       "comma coder: Width must be in interval [2,32]");

-        static constexpr size_t base_fits_in_64(uint32_t base, uint64_t product=0xFFFFFFFFFFFFFFFFULL, size_t res=0)
+        static constexpr size_t base_fits_in_64(uint32_t base, uint64_t product, size_t res)
         {
             return product==0 ? res : base_fits_in_64(base, product/base, res+1);
         }
@@ -73,7 +73,7 @@ class comma
         //table needed for computation of encoding lengths.
         //table contains entries of the kind (index, base^index)
         //to know how much digits a number needs to be encoded.
-        static const size_t codelentbllen = base_fits_in_64(base);
+        static const size_t codelentbllen = base_fits_in_64(base,0xFFFFFFFFFFFFFFFFULL,0);
         static std::array<uint64_t, codelentbllen> codelentbl;
simongog commented 9 years ago

Thanks again. Your help is much appreciated.