[Issue 9130] Wrong codegen for compile time constructed struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 10 08:30:48 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9130



--- Comment #2 from Max Samukha <samukha at voliacable.com> 2012-12-10 08:30:45 PST ---
(In reply to comment #1)
> It happens because of invalid usage of traits. If spec is right, getOverloads
> works with classes and even if it does work with structs, dmd complains "need
> 'this' for bar type void()"

Sorry, it is a valid usage. There should be no restrictions on the kind of
overloaded functions passed to getOverloads.

> 
> struct S
> {
>     void bar() { }
> }
> 
> void meta(alias m) ()
> {
>        // insert some usage of m here
>        // to force dmd to reject code
> }
> 
> void main()
> {
>     //Error: need 'this' for bar type void()
>     //auto x = __traits(getOverloads, S, "bar")[0];

Sure, calling a member function without a context pointer will and should
produce an error. Passing it to a template, storing in a tuple, getting its
type, static address and other meta-data are valid operations and should be
allowed.

>         //But template silently 'eats' erroneous construct
>     meta!(__traits(getOverloads, S, "bar")[0]);
> }
> 
> In your code if you comment out "meta!(__traits(getOverloads, S, "bar")[0]);"
> everything would work fine.

I need to use getOverloads. BTW, if you change S to a class and mark bar()
static you will get the same segfault.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list