#include <vector>
int main()
{
std::vector<int> v;
for (int x : v) do {} while (0);
}
Compiling the code above on VS2013 will yield error C2059: syntax error : '}'
. However, GCC can successfully compile the code.
To reproduce the error, the following requirements should be fulfilled:
Any insight on this?
这是一个错误,已在VS2015中修复。
You can use parentheses to avoid MSVC 2013 error. The following code is compiling fine in MSVC 2013 Update 4:
std::vector<int> v;
for (int x : v)
{
do
{
} while (0);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.