Unable to compile example boost::multiprecision with intel compiler on windows - c++

I am using VS 2017 Community edition, Intel Compiler 17.00 update 6 and and boost 1.66, trying to learn my way around boost::multiprecision::float128. Literally taking the example code from here and putting it in a new project for VS.
Compiling gives multiple errors, in roughly two categories/files:
In float128.hpp:
three errors of "error : identifier "xxx" is undefined" for fmaq, remquoq and remainderq. Indeed I am not able to find definitions for them - a missing include?
the global scope has no "signbitq" - this again looks like missing definition (i.e. the same as above)
For GCC the above functions are found within quadmath.h, however, the boost header doesn't seem to include it when using ICC (i.e BOOST_MP_USE_QUAD is set).
In C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\xutility: an explicit template argument list is not allowed on this declaration. There are three counts
I assume that i need to remove something that has been put in by default from the VS, but I am at a loss what exactly.
Thank you for your help
EDIT: Errors #2 above are actually not against boost at all (should I move this to a separate question?).
The following code copied from here! is not being compiled in my setup:
#include <iostream>
#include <string>
int main() {
std::string str("Test string");
for (std::string::iterator it = str.begin(); it != str.end(); ++it)
std::cout << *it;
std::cout << '\n';
return 0;
}
The exact error (one of them) is:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\xutility(680): error : an explicit template argument list is not allowed on this declaration
1> _INLINE_VAR constexpr bool _Is_iterator_v<_Ty, void_t<_Iter_cat_t<_Ty>>> = true;
1> ^
1> detected during:
1> instantiation of "const bool std::_Is_iterator_v [with _Ty=char *, <unnamed>=void]" at line 520 of "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\string"
1> instantiation of "std::basic_string<_Elem, std::char_traits<_Elem>, std::allocator<_Elem>> std::_Integral_to_string<_Elem,_Ty>(_Ty) [with _Elem=char, _Ty=int]" at line 554 of "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include\string"
I found this which indicates that there could be a problem with the particular versions used (ICC- 17.0 Up6 and VS 15.6), however i cannot really move to new intel compiler and i cannot test VS 15.4

I would like to write down how I managed to deal with error #2 from the original question, as it might be useful to someone.
Just as a reminder, the second errors I was seeing were in xutility. With the help of everyone that provided suggestions, it turned out that icc was in fact failing on very simple code - the following is enough to "break" it
int main() {
std::string str("Test string");
}
I have posted the question to intel's forums, however so far I have not received answers (for the 17.0 version of the compiler). Link here if anyone is interested.
That said, I came upon this blog post from the VC++ team, showing that the base toolset shown as v141 in VC2017 actually has had several minor revisions. It is possible to change the version of the MSVC toolchain but this needs to happen via editing of project files (rather than UI parameter changes).
My testing shows that version 14.11 (which is part of VS2017 15.3 and 15.4) works for Intel 17.0 while versions 14.12 and 14.13 (the last one is the current default for VS2017 15.6.4) do not. This has been done for Update 6 of the compiler. So in order to use the intel compiler on windows with visual studio, one needs to use particular MSVC toolchain versions.
Side note: I also installed icc version 18.0 update 1 for testing -- it too was giving compiler errors (and not just for me this time). The reason there though can be linked to some internal issue for icc, per this forum post. I can confirm that removing the compiler option /permissive- from the compiler fixes the errors irrespective of the base toolchain. Using v14.11 as base toolchain also fixes this particular problem for me with or without the option. /permissive- is a new option for icc (it is not part of 17.0).
The above solves more or less the second part of my problem with the icc. The rest of the question (boost's float128) though still remains. I will add more if i hear from boost's guys.
EDIT: the errors coming from boost turned out to be an issue there -- it was fixed by the maintainers in development branch, so this is resolved as well.

For Error #1, I got the same thing. However, after commenting the code blocks in boost float128.hpp where those four functions invoked, the float128 example code can be compiled with success. The side effect is unknown. I'm looking forward a revision on boost::multiprecision::float128.

Related

Locating error in source which is boost related [duplicate]

This question already has answers here:
C++ Boost: what's the cause of this warning?
(6 answers)
Closed 2 years ago.
I'm porting an old project from Boost 1.48 to Boost 1.61. The project is compiled using MSVC 2013. There are several reported errors during build which I think are boost related but unfortunately the bug reports are not very helpful at all.
3> entry.cpp
4>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(2715): error C2220: warning treated as error - no 'object' file generated
4>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(2715): warning C4996: 'std::_Fill_n': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
4> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(2701) : see declaration of 'std::_Fill_n'
4> c:\boost\boost_1_61_0\boost\random\detail\polynomial.hpp(114) : see reference to function template instantiation '_OutIt std::fill_n<boost::random::detail::polynomial_ops::digit_t*,size_t,boost::random::detail::polynomial_ops::digit_t>(_OutIt,_Diff,const _Ty &)' being compiled
4> with
4> [
4> _OutIt=boost::random::detail::polynomial_ops::digit_t *
4> , _Diff=size_t
4> , _Ty=boost::random::detail::polynomial_ops::digit_t
4> ]
I cannot see anything in the above that helps me identify where the problem is, there are no line numbers and the snippet of code is not from the compiled file.
#Eljay, does it have a human readable text option I could locate in the IDE? – SPlatten 43 mins ago
The thing you posted IS human readable text. It actually describes a warning with a reference to documentation. ¯\(ツ)/¯ Maybe you can just tell the compiler you don't want to receive warnings
In addition, you can use the keywords to google additional information:
C++ Boost: what's the cause of this warning?
Many libraries in addition already have a warning-suppression header (look for e.g. boost/iostreams/detail/config/disable_warnings.hpp or boost/random/detail/disable_warnings.hpp). The fact that known benign warnings "slip through" might indicate that the library needs to update their suppressions, OR you might need to upgrade your boost version.

Declaring a static pointer in class [duplicate]

While compiling on x64 plattform I am getting following error:
c:\codavs05\hpsw-sc\ovpacc\tools\codaaccesstest\coda_access.cpp(1572): fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\sizeopt.c', line 55)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
------ Build started: Project: asyncexample, Configuration: Release Win32 ------
If I change settings to preprocessor file (Yes) i am not getting any error.
About my environment: Upgrading Microsoft Visual Studio 2005 to 2010
Please help.
I have had this problem with VS2015 while building locally in Windows.
In order to solve it, I deleted my build folder (Output Directory as seen in Properties/General) and rebuilt the project.
This always seems to help when strange things happen during the build.
I’ve encountered this error many times in VC++. Do the following steps. They’ve sometimes helped me with this issue:
Take a look at the exact location, pointed out by compiler error.
Find any external types or classes used there at that location.
Change the order of “include path” of those files found in step 2 and rebuild the solution.
I hope that help !!!!
I am getting same error with VC2012. Setting up the project properties Optimization to Disabled (/Od) resolved the issue.
In my solution, i've removed output dll file of the project, and I've made project rebuild.
I encountered the same error and spent quite a bit of time hunting for the problem. Finally I discovered that function that the error was pointing to had an infinite while loop. Fixed that and the error went away.
In my case was the use of a static lambda function with a QStringList argument. If I commented the regions where the QStringList was used the file compiled, otherwise the compiler reported the C1001 error. Changing the lambda function to non-static solved the problem (obviously other options could have been to use a global function within an anonymous namespace or a static private method of the class).
I got this error using boost library with VS2017. Cleaning the solution and rebuilding it, solved the problem.
I also had this problem while upgrading from VS2008 to VS2010.
To fix, I have to install a VS2008 patch (KB976656).
Maybe there is a similar patch for VS2005 ?
I got the same error, but with a different file referenced in the error message, on a VS 2015 / x64 / Win7 build. In my case the file was main.cpp. Fixing it for me was as easy as doing a rebuild all (and finding something else to do while the million plus lines of code got processed).
Update: it turns out the root cause is my hard drive is failing. After other symptoms prompted me to run chkdsk, I discovered that most of the bad sectors that were replaced were in .obj, .pdb, and other compiler-generated files.
I got this one with code during refactoring with a lack of care (and with templates, it case that was what made an ICE rather than a normal compile time error)
Simplified code:
void myFunction() {
using std::is_same_v;
for (auto i ...) {
myOtherFunction(..., i);
}
}
void myOtherFunction(..., size_t idx) {
// no statement using std::is_same_v;
if constexpr (is_same_v<T, char>) {
...
}
}
I had this error when I was compiling to a x64 target.
Changing to x86 let me compile the program.
Sometimes helps reordering the code. I had once this error in Visual Studio 2013 and this was only solved by reordering the members of the class (I had an enum member, few strings members and some more enum members of the same enum class. It only compiled after I've put the enum members first).
In my case, this was causing the problem:
std::count_if(data.cbegin(), data.cend(), [](const auto& el) { return el.t == t; });
Changing auto to the explicit type fixed the problem.
Had similar problem with Visual Studio 2017 after switching to C++17:
boost/mpl/aux_/preprocessed/plain/full_lambda.hpp(203): fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'msc1.cpp', line 1518)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
Solved by using Visual Studio 2019.
I first encountered this problem when i was trying to allocate memory to a char* using new char['size']{'text'}, but removing the braces and the text between them solved my problem (just new char['size'];)
Another fix on Windows 10 if you have WSL installed is to disable LxssManager service and reboot the PC.

C++11 constexpr causes compiler's internal error (C1001)

I am using Visual Studio 2015 Update 3.
I get a fatal error:
(code C1001) : An internal error has occurred in the compiler.
Here is the code :
template<typename T>
constexpr T epsilon = std::numeric_limits<T>::epsilon();
I read it was fixed in Visual Studio Update 2. Can someone explain me why I am getting this error? Thanks in advance.
Any internal error (ICE) is a compiler bug. You get it because you have happened to trigger that bug. For this compiler you can report it at Microsoft Connect.
For such a report you need an example with an expected correct result, and the erroneous result.
The following test program compiles & runs nicely with MinGW g++ 5.1
#include <limits>
template<typename T>
constexpr T epsilon = std::numeric_limits<T>::epsilon();
#include <iostream>
using namespace std;
auto main() -> int
{
cout << epsilon<double> << endl;
}
Output:
2.22045e-016
With Visual C++ 2015 update 2 it produces an ICE:
foo.cpp(10): fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\symbols.c', line 28114)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
foo.cpp(10): note: see reference to variable template 'const double epsilon' being compiled
Compiler version:
> cl /nologo- 2>&1 | find "++"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23725 for x86
I've raised this as a bug with Microsoft, but they have had a fix since early 2017 which has not been released from what I can see as of today.
I've also provided a project on GitLab and given information to Microsoft for this project here: https://gitlab.com/cppocl/tostring
Loading the .sln and compiling currently crashes with Visual Studio 2015 update 2 or 3, and Visual Studio Enterprise 2017 version 15.3.1.
It does seem that the combination of template and constexpr causes the compiler to crash.
I've seen reports for Visual Studio 2017 describing similar types of problems.
This link says fixed pending release:
https://developercommunity.visualstudio.com/content/problem/18155/msvc-2017-c-fatal-error-c1001-constexpr-initializa.html
Visual Studio 2015 backlog of bugs relating to constexpr is here:
https://blogs.msdn.microsoft.com/vcblog/2015/12/02/constexpr-in-vs2015-update-1/
EDIT:
I also don't believe changing optimization settings will make any difference, as has been recommended in other posts.
I have experimented with these settings and applied recommended patches without success so far.

'TypeInfo<char>(char *)' isn't defined but worked pre-C++11; what changed, and how can I fix the error?

I am trying to build a DLL from source-code from the Crysis Wars SDK, and have successfully done so in the past on previous versions of Visual Studio (namely 2005, 2008, and 2010).
My specific problem is this:
Error 4 error LNK2019: unresolved external symbol "struct CTypeInfo const & __cdecl
TypeInfo<char>(char *)" (??$TypeInfo#D##YAABUCTypeInfo##PAD#Z) referenced in function
"void __cdecl SwapEndian<char>(char *,unsigned int)" (??$SwapEndian#D##YAXPADI#Z)
G:\Noctis\Mods\Noctis\Code\GameCVars.obj GameDll
I have attempted to clean the code in Visual Studio and rebuild it on the off-chance this'll work, but this has not changed anything.
Am I missing something here, or has something changed from C++03 to C++11 that means that this code is no longer compilable without reverting to an older version of C++?
I have successfully compiled this code on Visual Studio 2010 in both 64 bit and 32 bit, so it must be some issue related to migrating the project to Visual Studio 2015.
Compilation on 2012, 2013, and 2015 versions of Visual Studio reproduce this error but not 2010, so it seems that the change to trigger this problem was introduced in C++11.
What am I doing wrong?
Reading the answer to mem-fun is not a member of std, it could just be that I need to include a standard library that I didn't need to include in earlier versions of Visual Studio.
If this is true, which library would I need to #include?
I have also created a GitHub repository containing only the original unmodified code provided from the SDK, for testing purposes (in the event I myself made a typo, which doesn't seem to be the case here but I've put the link here as it may be helpful).
If it matters, I'm using Visual Studio 2015 Enterprise edition on Windows 10 Professional x64.
What does the error mean?
The error message hints towards a classic "declared but not defined" scenario.
TypeInfo<char>(char*) is declared in TypeInfo.h (through some macros) and declared in AutoTypeInfo.cpp in project CryCommon.
Usually you would just make sure the CryCommon project is built correctly and linked into your final GameDll project properly and that's it.
But it turns out here that the CryCommon project has not been built for a long time - it references many other Crytek libraries etc. So the problem must be that something now needs these TypeInfo<> definitions and previously it did not.
What is referencing the TypeInfo<> code?
In your project it's function CmdHelp() in Aurora/Code/GameCVars.cpp, precisely this line:
nRead = gEnv->pCryPak->FRead( buf, BUFSZ, f );
The implementation of the FRead() method is in CryCommon/ICryPak.h:
template<class T>
size_t FRead(T *data, size_t elems, FILE *handle, bool bSwap = true)
{
size_t count = FReadRaw(data, sizeof(T), elems, handle);
if (bSwap)
SwapEndian(data, count);
return count;
}
As you can see, if bSwap is true (the default), SwapEndian() is invoked there.
Why hasn't this manifested before?
Perhaps the compiler was indeed behaving differently.
Or, more likely, you have been always compiling the project as Release before. The whole byte-swapping functionality is enabled only on big-endian systems (and your target is most probably not one of those) or during debug - then the bytes are actually swapped twice to test the related code (see CryCommon/Endian.h).
What can be done to fix it?
You have several options now:
Keep compiling as release only (probably as before). Perhaps you will never be debugging the code in a debugger anyway.
Just comment the swap call in FRead() code out. You are using it to load a text file anyway, no point in swapping the characters around.
...
FWIW, other things I had to do to make your code compile:
Check out the earlier commit before "Broken"
Load Mods\Aurora\Code\Aurora.sln
Remove non-existing .vcprojx projects
Add all 3 .vcproj files again, let them be converted to VS2015 ones
For GameDll project, add preprocessor definition _SILENCE_STDEXT_HASH_DEPRECATION_WARNING
For GameDll project, set enabled C++ exception handling /EHsc
Comment out the code above

Very Mysterious/Random C++ WDK STL 7 Error: iosfwd(202): error C2144: syntax error

I have the following trivial file named Temp.cpp:
#include <string>
int main() { return 0; }
and I'm trying to compile it with the following command-line in the Windows XP Free Build Environment, using WDK 7.1:
cl.exe /Iinc\api\crt\stl70 /Iinc\crt C:\Temp.cpp
and I'm getting really random errors like:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.207 for 80x86
C:\WinDDK\7600.16385.1\inc\api\crt\stl70\iosfwd(202) :
error C2144: syntax error : 'int' should be preceded by ';'
The error goes away if I use stl60 instead of stl70, but that doesn't solve the problem.
What's the cause of the problem?
Update: I tried uninstalling and installing the WDK again, but nothing changed. :(
Update 2: Okay, apparently the error is screaming out at the header file itself: _SCL_INSECURE_DEPRECATE is the cause. Does anybody know how to turn it off correctly? (If I just comment out the lines, I get a ton more errors regarding a bunch of other macros.)
Found the answer myself, through modifying the headers and guess'n'checking:
I need to have _STL70_ defined.
Which cl.exe are you picking up? If your path happens to have an older (VC6) compiler before the WDK one, you'd expect these errors. VC6 can't compile the STL as shipped with VC7
apparently the error is screaming out at the header file itself: _SCL_INSECURE_DEPRECATE is the cause. Does anybody know how to turn it off correctly?
If you're having problems with _SCL_INSECURE_DEPRECATE, try setting:
/D_SCL_SECURE_NO_DEPRECATE
But given the error message you're seeing it sounds like you're the compiling headers with a a compiler that's older than the headers support (so this might not get you very far anyway).