I'm using Clang 3.6 with Visual Studio 2015 and I'm using this CRC32 implementation to generate hashes at compile time:
#define CRC32(message) (crc32_<sizeof(message) - 2>(message) ^ 0xFFFFFFFF)
static constexpr uint32_t crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
...
};
template<size_t idx>
constexpr uint32_t crc32_(const char * str)
{
return (crc32_<idx - 1>(str) >> 8) ^ crc_table[(crc32_<idx - 1>(str) ^ str[idx]) & 0x000000FF];
}
#pragma warning(push)
#pragma warning(disable : 4100)
// This is the stop-recursion function
template<>
constexpr uint32_t crc32_<size_t(-1)>(const char * str)
{
return 0xFFFFFFFF;
}
The problem is that when I use a string larger than 18 characters, clang-cl.exe
complains:
constexpr evaluation hit maximum step limit; possible infinite loop?
I've seen some answers about setting -fconstexpr-depth
or -fconstexpr-steps
. I try to pass that options back to Clang with clang-cl.exe
's parameter: -Xclang -fconstexpr-steps=10
but I get:
unknown argument: '-fconstexpr-steps=10'
The interesting thing is that I test the option with clang.exe
directly and it recognizes it.
My question is: is there a way to set constexpr steps or constexpr depth with clang-cl.exe
?
Use -Xclang -fconstexpr-steps -Xclang 10
clang with gcc-style transforms -fconstexpr-steps=10
into -fconstexpr-steps 10
, two separate arguments.
In order to transform two separate arguments from clang-cl
you should prefix it with -Xclang
two times
User contributions licensed under CC BY-SA 3.0