Unique-if LRM Clarification

Section 12.4.2 (unique-if) of the 2017 LRM says: “The presence of side effects in conditions may cause nondeterministic results.”, which is a little vague. Is it talking about something like this?


module tb;
    bit a, b;

    initial begin
        a = 1;

        unique if (a) begin
            $display ("a!");
            b = 1;
        end
        else if (b) begin
            $display ("b!");
        end
        else begin
            $display ("Nothing matched.");
        end

        $finish;
    end
endmodule : tb

It seems that half of the simulators issue a unique-if warning that a and b are both true, and the other half don’t.

In reply to sbellock:
The paragraph before the one you quoted explains your example better: “In unique-if and unique0-if, the conditions may be evaluated and compared in any order. The
implementation shall continue the evaluations and comparisons after finding a true condition.”

An expression with a side effect is just one specific case of that:

unique if (a++) begin
            $display ("a");
        end
        else if (!a++) begin
            $display ("a!");
        end

In reply to dave_59:

Thanks Dave. That was what I was looking for. I think because I would never do that in my own code it makes it difficult for me to come up with an example.