There is code in typechecker.cpp for checking that all initialisers are side-effect free; even those in functions. However as the attached model demonstrates, the logic is flawed (side-effect is not detected).
Created attachment 115 [details] Test case
Fixed on the 4.0 branch from rev. 2792 and on the trunk from rev. 2793.