← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/ai_return_added into lp:widelands

 

I am in a writing mode right now, so let me add one more thought :)

Be careful with assert()s in general. Actually, ideally do not use them. They are only executed in debug builds which means that release builds can break through them without you noticing (case in point: the breakage that we had with GCC here). I saw code like this before:

int a = 1;
assert(set_a_to_2(&a) == 1)

The semantics of this code changes between release and debug builds and nobody will ever notice.
And I saw that in production code before.

At work we take the stance that most assert()s are cheap enough to always run, even in production code. I think that is a good call since your code is 99% of the time executed by users in released binaries, so they will see much more failure cases than your debug build on your dev machine.

Google uses the glog library for their assert statements, which is pretty efficient: https://google-glog.googlecode.com/svn/trunk/doc/glog.html . see the CHECK macros. For example the error string is not evaluated when the CHECK passes, that makes them very cheap in most cases.


-- 
https://code.launchpad.net/~widelands-dev/widelands/ai_return_added/+merge/275638
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/ai_return_added.


References