I have a base-class with some virtual functions:

```
class cs
{
   <snip>
   virtual  void    Deactivate()    =   0;
   virtual  void    Update()    =   0;
   virtual  void    Render()    =   0;
   <snip>
};

```

I then derive a class from this base class, which has it's Update() and Render functions. Which I call, thus:

```
if (s_pActiveScene)
{
   s_pActiveScene->Update();
}

```

NOTE: s\_pActiveScene is a pointer to the derived class.

Everything works fine when I run the C code on iOS, Android, Mac. It also works on Windows in Debug mode (no optimisation). However the call (s\_pActiveScene->Update();) crashes on the Windows Release version (only with Whole Program Optimisation = Use Link Time Code Generation).

Is it a flaw with the compiler, or something I'm doing wrong?

EDIT: Getting same behavior from a new project, with minimal code as follows:

---- main.cpp

```
#include "cs.h"
#include "csMain.h"
int main(int argc, char* argv[])
{
    Main.ActivateThisScene();
    cs::DoUpdate();
    return 0;
}

```

---- cs.h

```
#pragma once
class cs
{
public:
    void    ActivateThisScene();
    static  void    DoUpdate();
    virtual void    Update()        =   0;
protected:
    static  cs*     s_pActiveScene;
};

```

---- cs.cpp

```
#include "cs.h"
cs* cs::s_pActiveScene = 0;
void cs::ActivateThisScene()
{
    s_pActiveScene = this;
}
void cs::DoUpdate()
{
    if (s_pActiveScene)
    {
        s_pActiveScene->Update();
    }
}

```

---- csMain.h

```
#pragma once
#include "cs.h"
extern  class   csMain  Main;
class csMain : public cs  
{
public:
    void    Activate();
    void    Update();
};

```

---- csMain.cpp

```
#include "csMain.h"
class   csMain  Main;
void
csMain::Activate()
{
    ActivateThisScene();
}
void
csMain::Update()
{
    return;
}

```