Superbelko / ohmygentool

LLVM/Clang based bindings generator for D language
The Unlicense
39 stars 6 forks source link

sizeof/typeof conversion takes wrong argument #1

Closed Superbelko closed 5 years ago

Superbelko commented 5 years ago

sizeof expanded in such way that it takes implicit "this" instead of actual member, such behavior introduces hard to find bugs like that example

struct Data
{
  void* data;
  int len;
  byte[32] buf;

  void reset() {
    memset(buf.ptr, 0, typeof(this).sizeof); // <- oops, last argument should be buf.sizeof
  }
}