Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
6a5c249d
Commit
6a5c249d
authored
Jul 19, 2019
by
Andrew Martin
Committed by
Marge Bot
Oct 08, 2019
Browse files
[skip ci] clarify what unsound means
parent
0c7a5bcd
Pipeline
#11110
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
docs/users_guide/ffi-chap.rst
View file @
6a5c249d
...
...
@@ -111,24 +111,30 @@ very difficult to track down. (The errors likely will not manifest
until garbage collection happens.) In tabular form, these restrictions
are:
+--------------------------------+-----------------------------------------------------+
| | When value is used as argument to FFI call that is |
+--------------------------------+-------------------------+---------------------------+
| | ``foreign import safe`` | ``foreign import unsafe`` |
+--------------------------------+-----------+-------------+-----------+---------------+
| Argument Type | reads are | writes are | reads are | writes are |
+--------------------------------+-----------+-------------+-----------+---------------+
| ``Array#`` | Unsound | Unsound | Sound | Unsound |
| ``MutableArray#`` | Unsound | Unsound | Sound | Unsound |
| ``SmallArray#`` | Unsound | Unsound | Sound | Unsound |
| ``MutableSmallArray#`` | Unsound | Unsound | Sound | Unsound |
| ``ArrayArray#`` | Unsound | Unsound | Sound | Unsound |
| ``MutableArrayArray#`` | Unsound | Unsound | Sound | Unsound |
| unpinned ``ByteArray#`` | Unsound | Unsound | Sound | Unsound |
| unpinned ``MutableByteArray#`` | Unsound | Unsound | Sound | Sound |
| pinned ``ByteArray#`` | Sound | Unsound | Sound | Unsound |
| pinned ``MutableByteArray#`` | Sound | Sound | Sound | Sound |
+--------------------------------+-----------+-------------+-----------+---------------+
.. table:: Restrictions on unlifted boxed arguments passed to foreign C calls.
Cells marked as "Unsound" represent combinations that lead to
undefined runtime behavior. GHC does not reject such unsound
programs at compile time.
:widths: auto
+--------------------------------+-----------------------------------------------------+
| | When value is used as argument to FFI call that is |
+--------------------------------+-------------------------+---------------------------+
| | ``foreign import safe`` | ``foreign import unsafe`` |
+--------------------------------+-----------+-------------+-----------+---------------+
| Argument Type | reads are | writes are | reads are | writes are |
+================================+===========+=============+===========+===============+
| ``Array#`` | Unsound | Unsound | Sound | Unsound |
| ``MutableArray#`` | Unsound | Unsound | Sound | Unsound |
| ``SmallArray#`` | Unsound | Unsound | Sound | Unsound |
| ``MutableSmallArray#`` | Unsound | Unsound | Sound | Unsound |
| ``ArrayArray#`` | Unsound | Unsound | Sound | Unsound |
| ``MutableArrayArray#`` | Unsound | Unsound | Sound | Unsound |
| unpinned ``ByteArray#`` | Unsound | Unsound | Sound | Unsound |
| unpinned ``MutableByteArray#`` | Unsound | Unsound | Sound | Sound |
| pinned ``ByteArray#`` | Sound | Unsound | Sound | Unsound |
| pinned ``MutableByteArray#`` | Sound | Sound | Sound | Sound |
+--------------------------------+-----------+-------------+-----------+---------------+
When passing any of the unlifted array types as an argument to
a foreign C call, a foreign function sees a pointer that refers to the
...
...
Marge Bot
💬
@marge-bot
mentioned in merge request
!900 (closed)
·
Oct 08, 2019
mentioned in merge request
!900 (closed)
mentioned in merge request !900
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment