benchmark
benchmark copied to clipboard
[BUG] Build fails in benchmark.cc with Clang 13 on Windows
Describe the bug
Clang 13 on Windows emits an error on compilation of benchmark.cc
:
..\..\3rdparty\benchmark\src\benchmark.cc(173,17): error: static_assert expression is not an integral constant expression
static_assert(offsetof(State, error_occurred_) <=
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stddef.h(47,31): note: expanded from macro 'offsetof'
#define offsetof(s,m) ((::size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))
^
..\..\3rdparty\benchmark\src\benchmark.cc(173,17): note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stddef.h(47,32): note: expanded from macro 'offsetof'
#define offsetof(s,m) ((::size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))
^
1 error generated.
System Which OS, compiler, and compiler version are you using:
- OS: Windows 10
- Compiler and version: Clang 13.0.0, Visual Studio 2019 16.11.5
Additional Information:
Defining _CRT_USE_BUILTIN_OFFSETOF
as mentioned in stddef.h
lets the file compile successfully.