Strange MSVC17 compiler behavior: WA1 when structured bindings are used while reading input

Revision en1, by CtrlAlt, 2021-07-16 19:08:56

When I solve problems on Codeforces I use primarily Microsoft Visual C++ compiler, and its currently latest version available on the site is 2017.

Occasionally I noticed that some of my correct submissions got WA1, and I usually got AC by resubmitting the same code with G++ compiler chosen. So far, I have not had time to deal with this issue in more detail. But today this situation has happened again, so I decided to figure it out.

Apparently the problem is with reading the contents of pairs or structures in a vector via structured bindings. Few examples: 122689729 vs 122691303 and 122691453 vs 122691571

Curiously, printing similar values via structured bindings causes no problems.

According to this page, the structured bindings are supported in MSVC since version 2017 15.3. I've managed to find an environment with 2017 15.9.9 compiler version, and the abovementioned problems do not appear there.

Unfortunately, the specific version of MSVC compiler used on Codeforces was not explicitly stated. MikeMirzayanov, if you have time, could you please update the compiler if its minor version is too old. Also, it would be great to update the page with a list of actual compilers and their options. Thanks in advance!

Tags ms visual c++, compiler, #bug

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English CtrlAlt 2021-07-16 19:08:56 1767 Initial revision (published)