I have checked the current master with CppCheck (free open source tool - highly recommended), and there's a couple of potential issues:
Code: Select all
[bitboards.c:167]: (error) Shifting by a negative value is undefined behaviour
[bitboards.c:168]: (error) Shifting by a negative value is undefined behaviour
[bitboards.c:164]: (error) Shifting 64-bit value by 72 bits is undefined behaviour
[bitboards.c:165]: (error) Shifting 64-bit value by 70 bits is undefined behaviour
[bitboards.c:167]: (warning) Suspicious code: sign conversion of - in calculation, even though - can have a negative value
[bitboards.c:168]: (warning) Suspicious code: sign conversion of - in calculation, even though - can have a negative value
[eval.c:272]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
[eval.c:273]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
[eval.c:274]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
[board.c:97]: (warning) %lx in format string (no. 1) requires 'unsigned long' but the argument type is 'unsigned long long'.
[board.c:444]: (style) Opposite expression on both sides of '&'.
[transposition.c:21]: (error) Common realloc mistake: 'tt' nulled but not freed upon failure
[timemanager.h:36] -> [timemanager.c:26]: (style, inconclusive) Function 'createFixedNodesTm' argument 1 names different: declaration 'depth' definition 'nodes'.
[uci.c:195]: (warning) %lu in format string (no. 3) requires 'unsigned long' but the argument type is 'unsigned long long'.
[uci.c:195]: (warning) %lu in format string (no. 4) requires 'unsigned long' but the argument type is 'unsigned long long'.
[search.c:27]: (warning) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'unsigned long long'.
[search.c:27]: (warning) %lu in format string (no. 2) requires 'unsigned long' but the argument type is 'unsigned long long'.
[search.c:414]: (warning) %lu in format string (no. 2) requires 'unsigned long' but the argument type is 'unsigned long long'.
[search.c:437]: (warning) %lu in format string (no. 2) requires 'unsigned long' but the argument type is 'unsigned long long'.
[search.c:502]: (style) The scope of the variable 'j' can be reduced.
[search.c:502]: (style) The scope of the variable 'key' can be reduced.
[search.c:503]: (style) The scope of the variable 'keyMove' can be reduced.
Especially the undefined behaviour is dangerous because it means the compiler is free to generate any code, actually for the whole program and not only the impacted function. GCC has a track record of ever more aggressive optimisations that rely on the absence of any undefined behaviour.
Also, I would benchmark the engine with and without strict pointer aliasing. If there is no considerable performance hit when you disable strict pointer aliasing, I would leave it disabled. In practice, the involved risk of undefined behaviour is more risky than what it's worth, at least for releases.
Next, if you are under Linux, have a look at GCC's ton of "sanitizer" options, and use all of them - including the pointer aliasing checks.