Bizarre compiler error?!

Can anyone offer any help? I have the wierdest error I have ever seen. Here’s the code:

Code:

void Graphics::setVisible(int gfxID,bool flag)
{
mgtVisibleOld[gfxID] = mgtVisible[gfxID];
mgtVisible[gfxID] = flag;
//<<EB there is a MASSIVE fault here, with mgtVisible being over-written! Compiler error??!
if (mgtVisible[gfxID] != mgtVisibleOld[gfxID]) // this statement CAN change mgtVisible
{
mgtChanged[gfxID] = true;
}
}

When executed, the line “if (mgtVisible[gfxID] != …” actually changes the value of mgtVisible[gfxID]. I am not over-running any array there, so I have no idea what is going on.
This is using VC++ 2005.

Thanks in advance!
Ed

If it’s a compiler error, go ask your compiler maker. This code fragment
alone is of no use for even guessing what might happen.
It’s C++, so [] might be overloaded very nasty. And it’s not SDL related…

Have you stepped thru it with the debugger?Am 29.01.2011 00:15, schrieb ebyard:

Can anyone offer any help? I have the wierdest error I have ever seen.
Here’s the code:

Code:

void Graphics::setVisible(int gfxID,bool flag)
{
mgtVisibleOld[gfxID] = mgtVisible[gfxID];
mgtVisible[gfxID] = flag;
//<
if (mgtVisible[gfxID] != mgtVisibleOld[gfxID]) // this statement CAN
change mgtVisible
{
mgtChanged[gfxID] = true;
}
}

When executed, the line “if (mgtVisible[gfxID] != …” actually
changes the value of mgtVisible[gfxID]. I am not over-running any array
there, so I have no idea what is going on.
This is using VC++ 2005.

Thanks in advance!
Ed


Christoph Nelles

E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt

I’d also check to see whether gfxID is being changed during this call
(fn getting called from multiple threads?) Otherwise, maybe reverse
the if statement to use an == comparison (then mark it changed in the
else clause).On Fri, Jan 28, 2011 at 6:49 PM, Christoph Nelles wrote:

If it’s a compiler error, go ask your compiler maker. This code fragment
alone is of no use for even guessing what might happen.
It’s C++, so [] might be overloaded very nasty. And it’s not SDL related…

Have you stepped thru it with the debugger?

Am 29.01.2011 00:15, schrieb ebyard:

Can anyone offer any help? I have the wierdest error I have ever seen.
Here’s the code:

Code:

void Graphics::setVisible(int gfxID,bool flag)
{
? ?mgtVisibleOld[gfxID] = mgtVisible[gfxID];
? ?mgtVisible[gfxID] = flag;
? ?//<
? ?if (mgtVisible[gfxID] != mgtVisibleOld[gfxID]) // this statement CAN
change mgtVisible
? ?{
? ? ? mgtChanged[gfxID] = true;
? ?}
}

When executed, the line “if (mgtVisible[gfxID] != …” actually
changes the value of mgtVisible[gfxID]. I am not over-running any array
there, so I have no idea what is going on.
This is using VC++ 2005.

Thanks in advance!
Ed


Christoph Nelles

E-Mail ? ?: evilazrael at evilazrael.de
Jabber ? ?: eazrael at evilazrael.net ? ? ?ICQ ? ? ? : 78819723

PGP-Key ? : ID 0x424FB55B on subkeys.pgp.net
? ? ? ? ? ?or http://evilazrael.net/pgp.txt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi Ed,

This might be a case where the code is optimized too much
and the debugger can’t precisely stop at the exact line
number you are at. I’m just guessing. This can easily happen
if you compile with maximum optimization level.

I suggest (if this is the case) to rebuild with less optimization
and see if it still happens.

Kind regards,
Kees BakkerOn 29 Jan, 2011, at 24:15 , ebyard wrote:

Can anyone offer any help? I have the wierdest error I have ever seen. Here’s the code:

Code:

void Graphics::setVisible(int gfxID,bool flag)
{
mgtVisibleOld[gfxID] = mgtVisible[gfxID];
mgtVisible[gfxID] = flag;
//<
if (mgtVisible[gfxID] != mgtVisibleOld[gfxID]) // this statement CAN change mgtVisible
{
mgtChanged[gfxID] = true;
}
}

When executed, the line “if (mgtVisible[gfxID] != …” actually changes the value of mgtVisible[gfxID]. I am not over-running any array there, so I have no idea what is going on.
This is using VC++ 2005.

Thanks in advance!
Ed


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks for the help guys, and I know it’s not SDL related, but it’s driving me mad.

If you can create a minimal test app that shows the problem, I will help
debug the issue on my system since I have Visual Studio 2005.

KenFrom: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of ebyard
Sent: Saturday, January 29, 2011 12:45 PM
To: sdl at lists.libsdl.org
Subject: Re: [SDL] bizarre compiler error?!

Thanks for the help guys, and I know it’s not SDL related, but it’s driving
me mad.

Ahh this has to be a memory corruption issue. Any line of code whatsoever changes the value of that variable!