   access violation with std::list
  Dear All,I really can't figure out what is going on with this piece of code. It gives an access violation in a list of double's, XAxisValues, whenever I try to add something to it. I have two similar lists, and they do exactly what I want them to.please help me with this one, I'm getting frustrated :(//IRPanel.h#include <wx/wx.h>#include <list>;class IRPanel : public wxPanel{public:    IRPanel(wxWindow* parent);    void OnPaint(wxPaintEvent& event);void OnSize(wxSizeEvent & event);void CalcAxisValues();private:wxString XLabel;wxString YLabel;std::list<double> XAxisValues;std::list<double> YAxisValues;std::list<wxString> XAxisLabels;std::list<wxString> YAxislabels;std::list<int> XAxisLabelsXPos;std::list<int> YAxisLabelsYPos;int XAxisLabelsYPos;int YAxisLabelsXPos;int ClientWidth, ClientHeighth;int XLabelLength, XLabelHeighth,YLabelWidth, YLabelHeighth,LabelSpacer,AxisSpacer,NumXLabels;int AxisLabelFontSize, AxisValuesFontSize, AxisArrowSize;double FirstX,LastX,MinX,MaxX,FirstY,LastY,MinY,MaxY, XDif, YDif, AbsXDif, AbsYDif;};//IRPanel.cpp, only constructor for now#include "IRPanel.h"IRPanel::IRPanel(wxWindow* parent): wxPanel (parent, wxID_ANY,wxDefaultPosition, wxDefaultSize,wxFULL_REPAINT_ON_RESIZE,wxT("")){  this-&gt;Connect(wxEVT_PAINT, wxPaintEventHandler(IRPanel::OnPaint));  this-&gt;Connect(wxEVT_SIZE, wxSizeEventHandler(IRPanel::OnSize));  XLabel=wxT("X-Label");  YLabel=wxT("Y-Label");  GetTextExtent(XLabel, &XLabelLength, &XLabelHeighth,(int*)0, (int*)0,wxSWISS_FONT);  GetTextExtent(YLabel, &YLabelWidth, &YLabelHeighth,(int*)0, (int*)0,wxSWISS_FONT);  LabelSpacer=5;  AxisSpacer=2*YLabelHeighth+3*LabelSpacer; //distance of axis to window border  AxisLabelFontSize=10;  AxisValuesFontSize=10;  AxisArrowSize=5;  FirstX=-1400;  LastX=400;  MinX=0;  MaxX=1;  FirstY=0;  LastY=1;  MinY=0;  MaxY=100;  XAxisValues.push_back(FirstX); //here it all goes wrong  XAxisLabels.push_back(wxT("label"));//this works!  XAxisLabelsXPos.push_back(AxisSpacer);//this too.};[Edited by - twoaterisn on May 10, 2010 5:51:14 AM]
  So i did some more digging... The first std::list I add to my class gives access violations upon calling push_back, push_front and clear, independent of which type of list it is (int, bool, double,...). The empty() call works however.I can get the program running by adding a dummy list which i don't use to the class declaration. However, when i shut things down, the destructor calls clear() on my dummy list and voila, access violation.I don't get it.   ;  Are you sure your IRPanel instance is valid (Not deleted, etc)? If it was invalid, empty() might work because it just reads a value, whereas calling anything "complicated" like clear(), push_back(), etc will try to interpret some of that memory as a pointer and then crash when its accessed.   ;  Show your code where you create an instance of IRPanel.   ;  I guess it must be valid, since I can do anything I want with the other lists I declare in the class...plus, I'm calling push_back() in the IRPanel class constructor, so the instance has only just been created, or is in the process of being created.main.h:#include <wx/wx.h>class MyApp : public wxApp{  public:    virtual bool OnInit();};main.cpp:#include "main.h"#include "IRPanel.h"IMPLEMENT_APP(MyApp)bool MyApp::OnInit(){wxFrame *Application = new wxFrame(NULL, wxID_ANY, wxT("Test"), wxDefaultPosition, wxSize(250, 150));    IRPanel *panel = new IRPanel(Application);    Application->Show(true);    return true;};  We're not seeing any problem with what you've posted, therefore could you please post a minimal but complete and compileable example program that produces the problem.   