I have a structure that contains, among other things, a couple of lines.
struct item { string item_name; int item_property_1; double item_property_2; }
Later I initialize them:
item item1; item1.item_name = "Name of Item"; item1.item_property_1 = 5; item1.item_property_2 = 10.0;
If I comment on the line that assigns the line, it works fine. When a line is assigned, it will work. I have no idea why.
Now I have commented on the contents of every other function, trying to track what might cause the alleged damage, and it still crashes. I got to one structure with several lines and numbers, and if I assign a value to any of the lines, it will work.
What could lead to this corruption?
edit Adding, upon request, the least amount of real code that causes a crash. Commented sections are omitted.
struct player_c { string advClass; int role; }; player_c shadow; Shadow::Shadow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Shadow) { ui->setupUi(this); shadow.advClass = " "; shadow.role = 1; }
That is all that remains. I just turned on int to verify and verify that assigning a value to it worked fine, and as long as the line is commented out. Any use of strings in the structure will fail.
I DO NOT NEED them there. I do not currently use these lines, I put them in the structure because I intend to use them later, but I can accomplish the same goal without them. Now I just want to understand why.