dthuerck / mapmap_cpu

A high-performance general-purpose MRF MAP solver, heavily exploiting SIMD instructions.
BSD 3-Clause "New" or "Revised" License
102 stars 51 forks source link

Variable length array causes issues when compiling with MSVC #14

Closed h00shi closed 5 years ago

h00shi commented 5 years ago

Hi,

In the file mapmap_cpu/mapmap/source/tree_sampler_instances/lock_free_tree_sampler.impl.h line 475 a variable length array has been defined: luint_t buf[m_buf_edges]; This is fine when compiling with gcc, but on MSVC it seems to cause compilation errors.

Maybe changing const luint_t m_buf_edges = 4; to static constexpr luint_t m_buf_edges = 4; in lock_free_tree_sampler.h can help.

Thanks

dthuerck commented 5 years ago

Thanks for reporting that! I'll change it from a variable length array to a dynamically allocated one.

h00shi commented 5 years ago

Thank you for your quick reply and fixing the problem. There is still one issue about the fix.

I think it should be std::unique_ptr<luint_t[]> buf = std::unique_ptr<luint_t[]>(new luint_t[m_buf_edges]); rather than std::unique_ptr<luint_t> buf = std::unique_ptr<luint_t>(new luint_t[m_buf_edges]); Otherwise, it would cause the same issue as #9.

dthuerck commented 5 years ago

Hi,

you are - again - absolutely right! Thanks, I've just pushed that update. Sorry for the delay, though.

h00shi commented 5 years ago

Thank you for the fix.