Skip to content

Commit

Permalink
Add documentation about Undefined Behavior (#6302)
Browse files Browse the repository at this point in the history
## Description

Add a section in the docs to list known UB.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
IGI-111 authored Jul 26, 2024
1 parent 62e7342 commit d31334d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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.

0 comments on commit d31334d

Please sign in to comment.