Skip to content

Commit dd7a7f5

Browse files
Bolpatthewilsonator
authored andcommitted
Merge changelog entries for null dereference checks
1 parent f348fc7 commit dd7a7f5

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

changelog/dmd.nullderef-safeonly.dd

Lines changed: 0 additions & 20 deletions
This file was deleted.

changelog/dmd.nullderefcheck.dd

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
An optional check for null dereference is added
1+
Checks for null dereferences
22

33
A new check has been implemented that injects code to check a pointer for null before it is dereferenced.
44

5-
It will be typically be used if you need a backtrace generated (when one is not automatically done), or if you want to catch and handle the `Error` as part of a scheduler.
5+
It will be typically be used if you need a backtrace generated or you want to catch and handle the `Error` as part of a scheduler.
66

7-
This can be enabled by using ``-check=nullderef=on`` by default it is off.
8-
What happens may be customized by the ``-checkaction`` switch and by setting a new handler in ``core.exception``.
7+
This can be enabled for all functions by using `-check=nullderef=on` or exclusively for `@safe` functions with `-check=nullderef=safeonly`
8+
By default it is off.
9+
What happens may be customized by the `-checkaction` switch and by setting a new handler in `core.exception`.
10+
11+
---
12+
@safe void foo()
13+
{
14+
int* p;
15+
// if -check=nullderef=on or -check=nullderef=safeonly is set:
16+
int x = *p; // null dereference error thrown at runtime
17+
}
18+
19+
@system void bar()
20+
{
21+
int* p;
22+
// if -check=nullderef=on is set:
23+
int x = *p; // no explicit check; relies on OS signal/exception
24+
}
25+
---
926

1027
Due to issues in dmd's backend, not all pointer dereferences are guaranteed to get a check.

0 commit comments

Comments
 (0)