- The __declspec(align) struct is not allowed in functions in Visual Studio 2015 RC.
- Exception objects have to be either copyable or movable. The following code compiles in Visual Studio 2013, but does not compile in Visual Studio 2015:
struct S {
public:
S();
private:
S(const S &);
};
int main()
{
throw S(); // error
}
or
struct S {
S();
explicit S(const S &);
};
int main()
{
throw S(); // error
}
- Capturing the exception by value requires the exception object to be copyable. The following code compiles in Visual Studio 2013, but does not compile in Visual Studio 2015:
struct B {
public:
B();
private:
B(const B &);
};
struct D : public B {
};
int main()
{
try
{
}
catch (D) // error
{
}
}
- The mutable specifier can be applied only to names of class data members(9.2). They cannot be applied to
names that are declared const or static, and also cannot be applied to reference members. For example:
class X {
mutable const int* p; // OK
mutable int* const q; // ill-formed
};
To work around this issue, simply remove the redundant "mutable" instance.
- We used to generate a ctor or dtor for the anonymous union that is non-conformant in either C++03 or C++11. These are now deleted.
- The non-trivial constructor is no longer invoked for any anonymous struct members within a union. For example:
#include <stdio.h>
struct S {
~S(){ printf("~S()");}
};
union U{
struct {
S s;
};
~U(){}
};
int main()
{
U u;
return 0;
}
In versions that are earlier than Visual Studio 2015 RC, the struct prints ~S(). After Visual Studio 2015 RC, it prints nothing. Additionally, you receive the following warning message:
warning C4588: 'U::s': behavior change: destructor is no longer implicitly called
- The type of the explicit non-type template argument should match the type of the non-type template parameter. However, Visual Studio 2015 RC sometimes fails to validate this. For example, the following code is no longer allowed:
struct S2
{
void f(int);
void f(int, int);
};
struct Sink
{
template <class C, void (C::*Function)(int) const> void f();
};
void f()
{
Sink sink;
sink.f<S2, &S2::f>();
}
- Data members of unions can no longer have reference types.
- When you use the /Zc:forScope- command in Visual Studio 2015 RC, you receive the following warning message:
cl : Command line warning D9035: option 'Zc:forScope-' has been deprecated and will be removed in a future release
- Macros that immediately follow a string without any white space between the string and the macro are now interpreted as user-defined literal suffixes. For example:
//Before compiled
#define _x "there"
char* func() {
return "hello"_x;
}
int main()
{
char * p = func();
return 0;
}
When you compile the code, you receive the following error message:
test.cpp(52): error C3688: invalid literal suffix '_x'; literal operator or literal operator template 'operator ""_x' not found
test.cpp(52): note: Did you forget a space between the string literal and the prefix of the following string literal?
- The non-trivial constructor is no longer invoked for any anonymous struct members within a union. For example:
#include <stdio.h>
struct S {
S(){ printf("S()");}
};
union U{
struct {
S s;
};
U(){}
};
int main()
{
U u;
return 0;
}
In versions that are earlier than Visual Studio 2015 RC, the struct prints S(). In Visual Studio 2015 RC, it prints nothing. Additionally, you receive the following warning message:
warning C4587: 'U::s': behavior change: constructor is no longer implicitly called.
- In Visual Studio 2015 RC, the implicitly-declared copy constructor is deleted if there is a user-defined move constructor or a move-assignment operator.
- The concatenation of adjacent wide or raw string literals now requires a space to be inserted (L"Hello" L"World"), because the prefix for the second string is now treated as a user-defined literal suffix. For example:
- const wchar_t *s = L"Hello"L"World"; // emits error C3688: invalid literal suffix 'L'; literal operator or literal operator template 'operator ""L' not found
- const wchar_t *t = L”Hello” L”World”; // compiles without error