moves-rwth / storm

A Modern Probabilistic Model Checker
https://www.stormchecker.org
GNU General Public License v3.0
126 stars 73 forks source link

Use some sort of `const` modifier in `STORM_LOG_ASSERT` implementation? #515

Closed linusheck closed 3 months ago

linusheck commented 3 months ago

Hi, I was just bit by a silly error where I had something with side effects in my STORM_LOG_ASSERT, which was not executed in release mode. My idea was to add something into STORM_LOG_ASSERT that ensures that there are no side effects, but this apparently cannot be done, because constexpr is actually compile-time and there is no alternative that checks for "no side effects", e.g. only const function invocations (which I know can have side effects) and their compositions with simple operators (which can of course also have side effects)

linusheck commented 3 months ago

ok, it seems like

linusheck commented 3 months ago

https://stackoverflow.com/questions/10593492/catching-assert-with-side-effects

This has a cool way of catching that the compiler knows an expression has no side-effects, but the Storm codebase is not a large legacy codebase, so this would be super overkill and it's fine as it is :)