joboccara / NamedType

Implementation of strong types in C++
MIT License
766 stars 85 forks source link

sizeof(Meter) != sizeof(double) with Visual Studio 2019 #51

Open emmenlau opened 3 years ago

emmenlau commented 3 years ago

Thanks for the excellent library! I've added NamedType to our CI and enabled the tests, but the tests fail with Visual Studio 2019 16.7.7 (current latest). I've tested with both the MSVC compiler and the supplied ClangCl. The error I get is:

1: C:\gitlabci\NamedType\test\tests.cpp(504): FAILED:
1:   REQUIRE( sizeof(Meter) == sizeof(double) )
1: with expansion:
1:   16 == 8
1: 
1: ===============================================================================
1: test cases: 37 | 36 passed | 1 failed
1: assertions: 79 | 78 passed | 1 failed

I've checked the code and as far as I can see FLUENT_EBCO is correctly defined as __declspec(empty_bases). I'm not sure why the sizes may be wrong, then. Any help would be appreciated!

pemessier commented 3 years ago

I think it's a bug in VS: https://developercommunity.visualstudio.com/content/problem/715068/-declspec-empty-base-not-working-in-variadic-templ.html

By the way, I have the same problem with this test in MSVC

acopy commented 3 years ago

Same issue using clang with msvc headers (Clang 12.0.0 x86_64-pc-windows-msvc) while with clang/mingw32 (Clang 11.0.0 (x86_64-w64-windows-gnu) the test passes.

emmenlau commented 2 years ago

Is there any update on this?