Skip to content

Replace most physical equality on immutable types#1597

Merged
sim642 merged 2 commits intomasterfrom
physical-equality
Oct 11, 2024
Merged

Replace most physical equality on immutable types#1597
sim642 merged 2 commits intomasterfrom
physical-equality

Conversation

@sim642
Copy link
Copy Markdown
Member

@sim642 sim642 commented Oct 11, 2024

The documentation on (==) says the following:

e1 == e2 tests for physical equality of e1 and e2. On mutable types such as references, arrays, byte sequences, records with mutable fields and objects with mutable instance variables, e1 == e2 is true if and only if physical modification of e1 also affects e2. On non-mutable types, the behavior of ( == ) is implementation-dependent; however, it is guaranteed that e1 == e2 implies compare e1 e2 = 0. Left-associative operator, see Ocaml_operators for more information.

And in fact there are cases where behavior differs between bytecode and native OCaml compilers. That depends on how much sharing is done. For example, in utop "foo" == "foo" evaluates to false.
The important point is that the implication between (==) and (=) is only one way. So physical non-equality does not imply structural non-equality.

In this PR I went though physical equality usage in Goblint and changed those which happen on immutable types. On int-like types this shouldn't actually make a difference in practice, but it's just better to not rely on implementation-defined behavior unnecessarily.
Most of these are probably typos from writing == like in other languages.

It's implementation-defined behavior that differs between bytecode and native OCaml compilers.
@sim642 sim642 added cleanup Refactoring, clean-up type-safety Type-safety improvements labels Oct 11, 2024
@sim642 sim642 added this to the v2.5.0 milestone Oct 11, 2024
It was already correct, but not obvious without looking up OCaml operator precedence.
@sim642
Copy link
Copy Markdown
Member Author

sim642 commented Oct 11, 2024

Apparently GitHub Actions' ubuntu-latest switched from 22.04 to 24.04 today, causing setup-ocaml to fail. So the CI failures here are unrelated and 412a7ab on master works around it for the time being.

@sim642 sim642 merged commit 425b1ee into master Oct 11, 2024
@sim642 sim642 deleted the physical-equality branch October 11, 2024 11:46
sim642 added a commit to sim642/opam-repository that referenced this pull request Nov 28, 2024
CHANGES:

Functionally equivalent to Goblint in SV-COMP 2025.

* Add 32bit vs 64bit architecture support (goblint/analyzer#54, goblint/analyzer#1574).
* Add per-function context gas analysis (goblint/analyzer#1569, goblint/analyzer#1570, goblint/analyzer#1598).
* Adapt automatic static loop unrolling (goblint/analyzer#1516, goblint/analyzer#1582, goblint/analyzer#1583, goblint/analyzer#1584, goblint/analyzer#1590, goblint/analyzer#1595, goblint/analyzer#1599).
* Adapt automatic configuration tuning (goblint/analyzer#1450, goblint/analyzer#1612, goblint/analyzer#1181, goblint/analyzer#1604).
* Simplify non-relational integer invariants in witnesses (goblint/analyzer#1517).
* Fix excessive hash collisions (goblint/analyzer#1594, goblint/analyzer#1602).
* Clean up various code (goblint/analyzer#1095, goblint/analyzer#1523, goblint/analyzer#1554, goblint/analyzer#1575, goblint/analyzer#1588, goblint/analyzer#1597, goblint/analyzer#1614).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Refactoring, clean-up type-safety Type-safety improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants