D-Scanner icon indicating copy to clipboard operation
D-Scanner copied to clipboard

Warn about calling non-const or non-pure functions in assert expressions

Open Hackerpilot opened this issue 9 years ago • 3 comments

This causes behavior to differ between debug and release builds.

Hackerpilot avatar Apr 26 '16 19:04 Hackerpilot

What is the rationale for this? Can you elaborate a bit more?

ljmf00 avatar Jul 17 '21 17:07 ljmf00

What is the rationale for this? Can you elaborate a bit more?

Side effects in asserts will not happen depending on whether the assert is included or not.

maxhaton avatar Jul 17 '21 23:07 maxhaton

void foo(ref int v) { v++; }

int x = 4;
assert(foo(x));
// x is now either 4 or 5

WebFreak001 avatar Jul 19 '21 14:07 WebFreak001