DIP 1028---Make @safe the Default---Community Review Round 1

jmh530 john.michael.hall at gmail.com
Wed Jan 15 19:13:50 UTC 2020

On Wednesday, 15 January 2020 at 18:26:31 UTC, Walter Bright 
> [snip]
>> I noticed that even templated class member functions are 
>> currently @system unless tagged @safe (for good reason). So 
>> there's going to be a lot of code out there like this.
> Templated functions get their safety inferred if not explicitly 
> marked.

Even for templated member functions? Running the code below 
causes an error. The way @safe flows through to nested scopes 
seems to override it.

import std;

@safe pure:

struct Foo {
     void foo(T)() {
         int x;
         int* y = &x;

     void bar() {

void main() {
     debug {
         writeln(hasFunctionAttributes!(Foo.foo!int, "pure"));
         writeln(hasFunctionAttributes!(Foo.bar, "pure"));

More information about the Digitalmars-d mailing list