www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14487] New: 'new' and 'delete' declarations doesn't accept

https://issues.dlang.org/show_bug.cgi?id=14487

          Issue ID: 14487
           Summary: 'new' and 'delete' declarations doesn't accept postfix
                    attributes
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: ketmar ketmar.no-ip.org

the following code raises alot of errors, 'cause compiler doesn't parse postfix
attributes on `new` and `delete` declarations:

class Foo {
   nogc this () {}

  new (size_t size)  trusted nothrow  nogc {
    import core.stdc.stdlib : malloc;
    auto res = malloc(size);
    if (res is null) {
      import core.exception : onOutOfMemoryError;
      onOutOfMemoryError();
    }
    return res;
  }

  delete (void* p) nothrow  nogc {
    import core.stdc.stdlib : free;
    free(p);
  }
}

void main () {
  auto f = new Foo();
  delete f;
}

--
Apr 23 2015