@@ -297,8 +297,7 @@ model as follows:
297
297
298
298
.. code-block :: solidity
299
299
300
- /// @solidity memory-safe-assembly
301
- assembly {
300
+ assembly ("memory-safe") {
302
301
...
303
302
}
304
303
@@ -327,8 +326,7 @@ But the following is:
327
326
328
327
.. code-block :: solidity
329
328
330
- /// @solidity memory-safe-assembly
331
- assembly {
329
+ assembly ("memory-safe") {
332
330
let p := mload(0x40)
333
331
returndatacopy(p, 0, returndatasize())
334
332
revert(p, returndatasize())
@@ -341,8 +339,7 @@ If the memory operations use a length of zero, it is also fine to just use any o
341
339
342
340
.. code-block :: solidity
343
341
344
- /// @solidity memory-safe-assembly
345
- assembly {
342
+ assembly ("memory-safe") {
346
343
revert(0, 0)
347
344
}
348
345
@@ -364,3 +361,16 @@ in memory is automatically considered memory-safe and does not need to be annota
364
361
It is your responsibility to make sure that the assembly actually satisfies the memory model. If you annotate
365
362
an assembly block as memory-safe, but violate one of the memory assumptions, this **will ** lead to incorrect and
366
363
undefined behaviour that cannot easily be discovered by testing.
364
+
365
+ In case you are developing a library that is meant to be compatible across multiple versions
366
+ of solidity, you can use a special comment to annotate an assembly block as memory-safe:
367
+
368
+ .. code-block :: solidity
369
+
370
+ /// @solidity memory-safe-assembly
371
+ assembly {
372
+ ...
373
+ }
374
+
375
+ Note that we will disallow the annotation via comment in a future breaking release, so if you are not concerned with
376
+ backwards-compatibility with older compiler versions, prefer using the dialect string.
0 commit comments