crash on std vector assignment

I keep getting a crash on assignment of a vector of a class to a vector of a class(they are the same type of course).

call stack:

std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() ()
Card::~Card(this=0x289e6972, __in_chrg=<value optimized out>)
std::_Destroy<Card>(__pointer=0x289e6972)
std::_Destroy_aux<false>::__destroy<__gnu_cxx::__normal_iterator<Card*, std::vector<Card> > >(__first=..., __last=...)
std::_Destroy<__gnu_cxx::__normal_iterator<Card*, std::vector<Card> > >(__first=..., __last=...)
std::_Destroy<__gnu_cxx::__normal_iterator<Card*, std::vector<Card> >, Card>(__first=..., __last=...)
std::vector<Card, std::allocator<Card> >::operator=(this=0x3649d0, __x=...)
Framework_ListItemViewer::Load(this=0x364870, CardData=..., EventQueue=0x27d9a00, type=2)
Core::LoadCardData(this=0x28f918)
main()

heres the class for the object:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class Card
{
    public:

    std::string Name;
    std::string FlipSideName;
    std::string Rarity;
    std::string Color;
    std::string Type;
    std::string Set;
    std::string Link;
    int Id;
    float LowPrice, HighPrice, AveragePrice;

    int CMC;
    int Power;
    int Toughness;
    int NumOf;
    int HasFlipSide;

    Card(std::string name, std::string rarity, std::string color, std::string type, std::string set,
         int cmc, int p, int t, int num, int flip, std::string flip_name): Id(0), LowPrice(0.0), HighPrice(0.0), 
AveragePrice(0.0), NumOf(0), HasFlipSide(NO_FLIP_SIDE)
    {
        Name = name;
        Rarity = rarity;
        Color = color;
        Type = type;
        Set = set;
        CMC = cmc;
        Power = p;
        Toughness = t;
        NumOf = num;
        HasFlipSide = flip;
        FlipSideName = flip_name;
    }

    Card(std::string name, std::string rarity, std::string color, std::string type, std::string set,
         int cmc, int p, int t, int num): Id(0), LowPrice(0.0), HighPrice(0.0),
 AveragePrice(0.0), 
NumOf(0), HasFlipSide(NO_FLIP_SIDE)
    {
        Name = name;
        Rarity = rarity;
        Color = color;
        Type = type;
        Set = set;
        CMC = cmc;
        Power = p;
        Toughness = t;
        NumOf = num;
    }

    Card& operator= (const Card& NewCard) //assignment
    {
        Name = NewCard.Name;
        Rarity = NewCard.Rarity;
        Color = NewCard.Color;
        Type = NewCard.Type;
        Set = NewCard.Set;
        CMC = NewCard.CMC;
        Power = NewCard.Power;
        Toughness = NewCard.Toughness;
        NumOf = NewCard.NumOf;
        HasFlipSide = NewCard.HasFlipSide;
        FlipSideName = NewCard.FlipSideName;

        return *this;
    }

    Card (const Card& NewCard) //copy constructor
    {
        *this = NewCard;
    }

    Card(){}
    ~Card(){} //crashes on this line
};


Heres the initial line it crashes on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int Framework_ListItemViewer::Load(vector<Card> CardData, ALLEGRO_EVENT_QUEUE *EventQueue, int type)
{
    ListType = type;
    CardList = CardData; //crasehes on this. they are both std::vector<Card>

    if(FlipButton.Load(260, 300, 25, 25, "Buttons/FlipButton_Up.png", "Buttons/FlipButton_Selected.png") == -1)
    {
        return ShowMessageBox(al_get_current_display(), "Error", "Failed to load flip button", ALLEGRO_MESSAGEBOX_ERROR);
    }

    if(QuickSearchTxtBox.Load(290, 10, 250, 25, 18, 50, EventQueue) == -1)
    {
        return ShowMessageBox(al_get_current_display(), "Error", "Failed to load textbox", ALLEGRO_MESSAGEBOX_ERROR);
    }

    if(ScrollBar.Load(1165, 70, 25, 475, CardList.size(), MaxItemsDisplayed, 290, 10, 1165, 635) == -1)
    {
        return ShowMessageBox(al_get_current_display(), "Error", "Failed to load scroll bar", ALLEGRO_MESSAGEBOX_ERROR);
    }

    return 0;
}


Anyone have any idea whats causing this ???
I don't see the problem here. It is possible that it's caused by other parts of you program.
Yeah this is really bugging me. Does the call stack hint to any clues?
It just says it crash inside the string destructor. These kind of errors could be caused by memory corruption because you dereference a dangling pointer, access an array out of bounds, etc. It is not possible to see from the code you have posted what is wrong. You could try to use a debugger like valgrind helps you detect many memory-related errors.
Topic archived. No new replies allowed.