Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation about Undefined Behavior #6302

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
- [Attributes](./reference/attributes.md)
- [Style Guide](./reference/style_guide.md)
- [Known Issues and Workarounds](./reference/known_issues_and_workarounds.md)
- [Behavior Considered Undefined](./reference/undefined_behavior.md)
- [Differences From Solidity](./reference/solidity_differences.md)
- [Differences From Rust](./reference/rust_differences.md)
- [Contributing To Sway](./reference/contributing_to_sway.md)
Expand Down
15 changes: 15 additions & 0 deletions docs/book/src/reference/undefined_behavior.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Behavior Considered Undefined

Sway code that contains any of the following behavior is considered undefined.
The compiler is allowed to treat undefined Sway code however it desires,
including removing it or replacing it with any other Sway code.

This is not an exhaustive list, it may grow or shrink, there is no formal model
of Sway's semantics so there may be more behavior considered undefined. We
reserve the right to make some of the listed behavior defined in the future.

* Invalid arithmetic operations (overflows, underflows, division by zero, etc)
* Misuse of compiler intrinsics
* Incorrect use of inline assembly
* Reading and writing `raw_ptr` and `raw_slice`
* Slicing and indexing out of bounds by directly using compiler intrinsics.
Loading