skramm/homog2d

Compilation issues in MSVS 17.8.3

Closed this issue · 6 comments

Test code does not compile with MSVS 17.8.3

/std:c++14 option
homog2d.hpp(6257,87): error C2275: 'h2d::type::IsClosed': expected an expression instead of a type
homog2d.hpp(6257,72): error C2923: 'h2d::detail::PlHelper': 'h2d::type::IsClosed' is not a valid template type argument for parameter 'T'
homog2d.hpp(6257,24): error C2475: 'h2d::base::PolylineBase<T1,T2>::impl_set_RCP': redefinition; 'constexpr' specifier mismatch

/std:c++17 and /std:c++20 options
homog2d.hpp(6257,87): error C2275: 'h2d::type::IsClosed': expected an expression instead of a type
homog2d.hpp(6257,72): error C2923: 'h2d::detail::PlHelper': 'h2d::type::IsClosed' is not a valid template type argument for parameter 'T'
homog2d.hpp(6257,96): error C2955: 'h2d::detail::PlHelper': use of class template requires template argument list
homog2d.hpp(6257,58): error C2955: 'h2d::detail::PlHelper': use of class template requires template argument list
homog2d.hpp(6257,24): error C2475: 'h2d::base::PolylineBase<T1,T2>::impl_set_RCP': redefinition; 'constexpr' specifier mismatch

#include "homog2d.hpp"
using namespace h2d;
int main()
{
Line2d l1(Point2d(10, 10)); // a line passing through (0,0) and (10,10)
Line2d l2(Point2d(0, 10), Point2d(10, 0)); // a line passing through (0,10) and (10,0)
auto pt = l1 * l2; // intersection point (5,5)
Homogr H(2, 3); // a translation matrix
std::cout << H * pt; // prints [7,8]
}

skramm commented

Thanks for reporting, currently in a train 😉, I'll check that ASAP.

skramm commented

This is strange, I can't reproduce at first.
As I don't have a Windows machine, I can't try with Visual Studio, but using Compiler Explorer with latest MSVC doesnt trigger the failure:
https://godbolt.org/z/ch37basYb
Do you have a way to find out exactly what version of compiler are you using inside MSVC?
I'll keep on investigating on my side.

And again, thank you very much for reporting, these reports are very valuable (and its probably nothing to fix!).

Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33133 for x64
compiler options:
/c /ZI /JMC /W3 /WX- /diagnostics:column /sdl /Od /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /std:c++20 /permissive- /Fo"x64\Debug\" /Fd"x64\Debug\vc143.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt

Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30153 for x64 with same options compiles successfully (142 toolset for MSVS 2019)

The reason is C++->Language->Conformance mode option which is set to 'Yes(/permissive-)' by default. Setting this option to 'No' fixes problem.

Changing method signature to

template
std::pair<HOMOG2D_INUMTYPE,HOMOG2D_INUMTYPE>
impl_set_RCP( FPT2 rad, size_t n, const typename detail::PlHelper& );

also fixes problem.

Sorry don't know how to send patch correctly.

skramm commented

Ok, thanks for you support, not sure I would have managed that myself!
Unfortunately, CompilerExplorer does not seem to support release 19.38 of MSVC.
I just pushed on master the corrected version, where I added the "typename" in the signatures.
Let me know if any further build failures.