CompileTest fails with latest VS 2019 (16.5.4)
metablaster opened this issue · 6 comments
Since recent upgrade to VS 16.5.4 the "CompileTest" project fails in "Contexpr.cpp" on line 413
SafeInt\Test\ConstExpr.cpp:413
I tried to debug this but with no luck, basically exception handler gets called which isn't constexpr in compile time, the call should resolve at compile time.
Trace goes to SafeInt.hpp:6839
if (div_negate_min< T, U, sizeof(U) < sizeof(T) > ::Value(tmp))
basically here both T
and U
resolve to char type, and since sizeof(char) < sizeof(char)
is false, non constexpr exception handler is invoked and compile fails.
At least that's my understanding, unless I got this wrong, not sure how to approach this problem sorry.
Yes, it's the most recent compiler and tested on master branch with most recent commits.
Just to be 100% sure I redownloaded the repo for test and this is compiler output:
1>------ Build started: Project: CompileTest, Configuration: Debug x64 ------
1>Build started 22.4.2020. 11:47:07.
1>Target PrepareForBuild:
1> Creating directory "C:\Users\USERNAME\Desktop\SafeInt-master\Test\SafeIntTestVS17\x64\Debug\".
1> Creating directory "x64\Debug\CompileTest.tlog\".
1>Target InitializeBuildStatus:
1> Creating "x64\Debug\CompileTest.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
1>Target ClCompile:
1> CleanCompile.cpp
1> CompileTest.cpp
1> ConstExpr.cpp
1> C:\Users\USERNAME\Desktop\SafeInt-master\Test\ConstExpr.cpp(413,22): error C3615: constexpr function 'DivisionCornerCaseHelper2<T,U,E,1>::DivisionCornerCase2' cannot result in a constant expression
1> with
1> [
1> T=char,
1> U=char,
1> E=CPlusPlusExceptionHandler
1> ]
1> C:\Users\USERNAME\Desktop\SafeInt-master\SafeInt.hpp(6842,37): message : failure was caused by call of undefined function or one not declared 'constexpr'
1> C:\Users\USERNAME\Desktop\SafeInt-master\SafeInt.hpp(6842,37): message : see usage of 'SafeIntInternal::SafeIntExceptionHandler<SafeIntException>::SafeIntOnOverflow'
1> C:\Users\USERNAME\Desktop\SafeInt-master\Test\ConstExpr.cpp(530): message : see reference to function template instantiation 'void TestConstExpr::StaticAssertTU<T,char>(void)' being compiled
1> with
1> [
1> T=char
1> ]
1> C:\Users\USERNAME\Desktop\SafeInt-master\Test\ConstExpr.cpp(663): message : see reference to function template instantiation 'void TestConstExpr::StaticAssertTest<T>(void)' being compiled
1> with
1> [
1> T=char
1> ]
1> C:\Users\USERNAME\Desktop\SafeInt-master\Test\ConstExpr.cpp(674): message : see reference to function template instantiation 'void TestConstExpr::ConstExprTestT<char>(void)' being compiled
Oh, this is with the very most recent compiler. I was hoping that would be an older version, and I could just work around it. This is a bug on their end. Especially so since it is a regression. They would ideally be able to figure out that the exception branch of the code is never called, and not evaluate it for constexpr.
Just as a quick test, change this line in constexpr.cpp from:
#if !defined clang && defined GNUC && __cplusplus >= 201402L
to
#if 1
And it should go away. Let me know, and I'll start trying to get this to the VS team through internal mails.
OK, replacing the line did the trick, I see now what is the problem, but would never figure it out that it's a compiler to blame heh.
definitely worth reporting, thank you for your time!
It looks like it is a regression, and will be fixed in 16.6, they're discussing a back port. Thanks very much for letting me know. The above work-around will get you by in the meantime. The test is really just there to ensure that if I change something, it will still compile correctly. The more important test for a user is the runtime tests. This particular test is forcing something unusual to test whether constexpr is really correct up and down the call chain.
This is verified as fixed in 16.6.1