pointers, functions, and uniform call syntax

Artur Skawina art.08.09 at gmail.com
Thu Sep 6 03:58:24 PDT 2012


On 09/06/12 12:29, Artur Skawina wrote:
>    class C { int i; auto f() { return i; } }
>    int main() {
>       C c;
>       return c.f();
>    }
> 
> Here you won't even get an assert error, just a segfault. But the pointer-to-class

Argh. The reason you won't get get an assert is because I forgot to add
'final' when converting the struct example... 

   class C { int i; final f() { return i; } }
   int main() {
      C c;
      return c.f();
   }


BTW, why doesn't GDC figure this out by itself? IIRC GCC gets these
cases right both for C++ and C (!), but does not devirtualize D methods,
not even in LTO/WPR mode...

artur


More information about the Digitalmars-d mailing list