-6

I have been porting my code from Visual Studio 2017 to Visual Studio 2019. It was building properly before. But now I am getting these errors:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.20.27508\include\list(1010): error C2280: 'std::pair<_Kty,_Ty> &std::pair<_Kty,_Ty>::operator =(volatile const std::pair<_Kty,_Ty> &)': attempting to reference a deleted function        178 114
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.20.27508\include\list(1010): error C2280: 'std::pair<_Kty,_Ty> &std::pair<_Kty,_Ty>::operator =(volatile const std::pair<_Kty,_Ty> &)': attempting to reference a deleted function        54  114

These errors do not refer to lines in my code, so I can't see what I have written that might cause them. And this code built without error in earlier versions of the tools.

Here are the project properties of the failing build:

https://imgur.com/a/WnjmKRa

Note: most of the projects are building fine.

With Windows SDK Version set to 7.0 and Platform Toolset set to Visual Studio 2017 - Windows XP (v141_xp) the same project builds successfully. Snapshot showing that the project built fine with Windows SDK version 7 and Toolset v141_xp

I understand there is a problem in my code, somewhere, but it is not showing any error in any code that belongs to the project I am building, it is only showing the error in the list header.

I want to find the culprit code that is causing this build failure. What scenarios would make list give me these errors?

Why does it build fine with Windows SDK 7 and v141_xp toolset and, not with upgraded SDK and toolset?

StewieGGriffin
  • 349
  • 1
  • 4
  • 14
  • 7
    *"What could be causing this?"* - Your code – StoryTeller - Unslander Monica Apr 05 '19 at 06:26
  • Why didn't you just go to the line of code that is causing the issue? More than likely you are violating C++ rules, but it is impossible to know without seeing your code. – PaulMcKenzie Apr 05 '19 at 06:29
  • @StoryTeller Lol. Thanks. It solved my problem. – StewieGGriffin Apr 05 '19 at 08:01
  • 1
    @PaulMcKenzie That is because the build output is not telling me where the problem is in my code. It showing me only two errors and both of them are in `list`, as in `Professional\VC\Tools\MSVC\14.20.27508\include\list`; and of course, I have no control over those files, I know something has changed in `std::list` but I am not able to figure out what it is, that I need to do to fix it, as I don't know which part of the code is doing that, and there are over 350 projects in this solution and so many dependencies between projects. – StewieGGriffin Apr 05 '19 at 12:36
  • Y'know. I didn't leave a comment to make you feel stupid (yes, followed a twitter link). It really is impossible to help you with nothing but some screenshots and two lines of error message. @KateGregory may have edited your post, but that remained unchanged, "some folks" still see the same issue is there. – StoryTeller - Unslander Monica Apr 07 '19 at 17:09
  • @StoryTeller No worries man!! I didn't take it personally, and on Twitter, that was just an expression out of frustration. By the way, If I had seen/found the code that is causing `list` to behave this way I would have posted it here. But those two lines of error messages were all I got. I have been working on to find the culprit code but still no luck yet. – StewieGGriffin Apr 08 '19 at 05:02
  • @Abhishek Were you able to fix this problem? I'm actually having something similar.... – DieSlower Nov 11 '19 at 01:19

1 Answers1

1

Your project properties are possibly a red herring.

The error is that the type std::pair<_Kty,_Ty> has a deleted copy assignment operator, which can happen if various of its other constructors or assignment operators are explicitly defined or if the copy assignment operator is explicitly deleted. While std::list does not require T to be copy-assignable since c++11, you should perhaps double-check the std::lists that you are using in your program and see if you can make sure it's none of those that is leading up to this error.

To get better help you'll need to post an MCVE.

(long comment converted into Answer)

jcarpenter2
  • 5,312
  • 4
  • 22
  • 49