File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -467,14 +467,27 @@ $(GNAME VoidInitializer):
467
467
used before it is set, undefined program behavior will result.
468
468
)
469
469
470
- $(UNDEFINED_BEHAVIOR If a void initialized variable's value is
471
- used before it is set, the behavior is undefined .
470
+ $(IMPLEMENTATION_DEFINED If a void initialized variable's value is
471
+ used before it is set, its value is implementation defined .
472
472
473
473
---
474
- void foo ()
474
+ void bad ()
475
475
{
476
476
int x = void;
477
- writeln(x); // will print garbage
477
+ writeln(x); // print implementation defined value
478
+ }
479
+ ---
480
+ )
481
+
482
+ $(UNDEFINED_BEHAVIOR If a void initialized variable's value is
483
+ used before it is set, and the value is a reference, pointer or an instance
484
+ of a struct with an invariant, the behavior is undefined.
485
+
486
+ ---
487
+ void muchWorse()
488
+ {
489
+ char[] p = void;
490
+ writeln(p); // may result in apocalypse
478
491
}
479
492
---
480
493
)
Original file line number Diff line number Diff line change @@ -3233,6 +3233,8 @@ $(H3 $(LNAME2 safe-functions, Safe Functions))
3233
3233
$(LI No pointer arithmetic (including pointer indexing).)
3234
3234
$(LI Cannot access unions that have pointers or references overlapping
3235
3235
with other types.)
3236
+ $(LI Cannot access unions that have fields with invariants overlapping
3237
+ with other types.)
3236
3238
$(LI Calling any $(RELATIVE_LINK2 system-functions, System Functions).)
3237
3239
$(LI No catching of exceptions that are not derived from
3238
3240
$(LINK2 https://dlang.org/phobos/object.html#.Exception, $(D class Exception)).)
@@ -3244,6 +3246,7 @@ $(H3 $(LNAME2 safe-functions, Safe Functions))
3244
3246
$(LI Cannot access $(D __gshared) variables.)
3245
3247
$(LI Cannot use $(D void) initializers for pointers.)
3246
3248
$(LI Cannot use $(D void) initializers for class or interface references.)
3249
+ $(LI Cannot use $(D void) initializers for types that have invariants.)
3247
3250
)
3248
3251
3249
3252
$(P When indexing or slicing an array, an out of bounds access
You can’t perform that action at this time.
0 commit comments