Bug in the MSVS C++ compiler on Codeforces?

Revision en2, by _vanger_, 2023-06-23 04:54:21

I noticed a strange behavior when choosing the Microsoft Visual C++ 17 language. Structured binding is handled incorrectly.

Let's be concrete. I tried to solve that problem: https://codeforces.net/contest/1843/problem/E and noticed that exactly the same code leads to different decisions on different compilers. Namely, it was accepted when choosing G++17 (as well as G++20, Clang++20): https://codeforces.net/contest/1843/submission/210710990 and when choosing VC++17 it gave wrong answer on test 1: https://codeforces.net/contest/1843/submission/210711015 A small investigation showed that the problem was in the lines when I filled a vector of pairs using structured binding:

vector<pair<int, int>> segments(m);
for (auto& [l, r] : segments)
    cin >> l >> r;

^ not OK

As one can see from this submission: https://codeforces.net/contest/1843/submission/210711251 elements of the vector are not filled with input values for some reason, and remain the default zeroes. The problem was only with the vector of pairs. Vector of ints is initialized properly:

vector<int> xs(q);
for (auto& x : xs)
    cin >> x;

^ OK

I want to add that I couldn't reproduce the bug on my version of MSVC++ (Version 17.5.3). The problem was only with the compiler on the server. Is it some known bug of the MSVC++ compiler used on Codeforces? If it is, are there some more that are commonly known?

Tags bug, c++17, msvc++

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English _vanger_ 2023-06-23 04:54:21 176
en1 English _vanger_ 2023-06-23 04:35:41 1296 Initial revision (published)