Jump to content

Spell.cpp ASSERT


Guest The_Game_Master

Recommended Posts

Hello,

i recently got a crash on Spell.cpp line "ASSERT( Caster != NULL && info != NULL );" on linux.

I was wondering why do we use these 2 ASSERTS here

    ASSERT( Caster != NULL && info != NULL );
   ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element");

As far as i know in the release method the ASSERT command, or more commonly used as small letters assert is skipped.

Why do we need them, and why can't we just use small caps "assert" there?

Or just better remove them all.

I used

LDFLAGS=-L/usr/local/lib
LD_LIBRARY_PATH=/usr/local/lib
CXXFLAGS=-I/usr/local/include

autoreconf -ifv
autoconf

CFLAGS="-fno-strict-aliasing -O2" \\
CFLAGS="-fno-delete-null-pointer-checks -O2" \\
CXXFLAGS="-fno-strict-aliasing -O2" \\
../configure \\

to compile, so i'm guessing that the compiler didn't ignore all the aserts, or that line is used for something else inside the code and thats just stupid. What's the difference between "assert" and "ASSERT"?

Link to comment
Share on other sites

ASSERT is a macro that does a bit more before calling the standard C asssert().

And did you really ask why asserts are needed??

For exactly those situations like you experienced: Finding the cause of fatal errors and stop the program, rather than letting it happily crash later at a random position where you can only guess why it crashed, and hope it didn't cause too much fatal data corruption on its way...

Btw, assertions are not just magically "skipped in release mode" since there is no universal definition of that, C assert is defined to do nothing when NDEBUG is defined.

But seriously, i doubt you really want to disable them especially when they stop your program...

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use