mokhtar
14th January 2017, 09:47
Hello,
While debugging a strange compiler error in my project, I seem to have come across a weird bug in the MSVC compiler parser.
The problem occurs when having a duplicate using statement to create an alias for a templated class, and only if the <QCoreApplication> header file is included.
I'm trying to figure out if there is something inherently wrong in having the duplicate alias (is it legal C++?) or wether it is just a strange edge case that is happening in MSVC.
A simple test case which produces a compiler error can be found in the following gist, with details of my build environment:
https://gist.github.com/mnaamani/44a33f6820e7a97d056fce455e77aee7
Can anyone replicate the compiler error?
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xstring(1596): error C3536: '_Mydata': cannot be used before it is initialized
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xstring(1596): error C2440: '<function-style-cast>': cannot convert from 'int' to 'std::_String_iterator<std::_String_val<std::_Simple_types<wchar_t>>>'
Regards,
Mokhtar
Added after 31 minutes:
Its actually possible to produce the compiler error with just adding `#include <string>` so it doesn't appear to be specific to Qt.
While debugging a strange compiler error in my project, I seem to have come across a weird bug in the MSVC compiler parser.
The problem occurs when having a duplicate using statement to create an alias for a templated class, and only if the <QCoreApplication> header file is included.
I'm trying to figure out if there is something inherently wrong in having the duplicate alias (is it legal C++?) or wether it is just a strange edge case that is happening in MSVC.
A simple test case which produces a compiler error can be found in the following gist, with details of my build environment:
https://gist.github.com/mnaamani/44a33f6820e7a97d056fce455e77aee7
Can anyone replicate the compiler error?
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xstring(1596): error C3536: '_Mydata': cannot be used before it is initialized
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xstring(1596): error C2440: '<function-style-cast>': cannot convert from 'int' to 'std::_String_iterator<std::_String_val<std::_Simple_types<wchar_t>>>'
Regards,
Mokhtar
Added after 31 minutes:
Its actually possible to produce the compiler error with just adding `#include <string>` so it doesn't appear to be specific to Qt.