digitalmars.D.bugs - [Issue 8257] New: __traits(compiles) gives compile error
- d-bugmail puremagic.com (21/21) Jun 16 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8257
- d-bugmail puremagic.com (33/33) Oct 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8257
- d-bugmail puremagic.com (13/13) Oct 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8257
- d-bugmail puremagic.com (11/11) Oct 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8257
http://d.puremagic.com/issues/show_bug.cgi?id=8257 Summary: __traits(compiles) gives compile error Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: wfunction hotmail.com --- Comment #0 from wfunction hotmail.com 2012-06-16 19:11:34 PDT --- struct S { static void g() { } } auto f(string m)() { return &__traits(getMember, S.init, m); } // Error: delegates are only for non-static functions static if (__traits(compiles, f!"g"())) { } Marked as critical since there's no real workaround (that I'm aware of)... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 16 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8257 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au --- Comment #1 from Don <clugdbug yahoo.com.au> 2012-10-19 04:14:25 PDT --- The error is not coming from __traits(compiles), it happens while generating the obj file. If you compile with dmd -c -o- then no error occurs. The error message itself should I think be regarded as an internal compiler error. Here's the root cause. struct S { static void g() { } static int w;} void main() { S s; auto k = &s.g; pragma(msg, typeof(&s.g)); } This compiles with -c -o- According to the pragma, &s.g is a delegate. But, since g is a static function, it cannot be a valid delegate. The error is detected only at the glue layer. I believe that &s.g should be a function pointer, and s should be ignored, since already: int *x = &s.w; // accepted, s is ignored s.g(); // accepted, s is ignored. This would mean the __traits in the original code would continue to return true, but the function f!"g"() would actually be valid and would return a function pointer, not a delegate. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8257 --- Comment #2 from github-bugzilla puremagic.com 2012-10-20 20:27:21 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/95d00b2f0ae25d74e0091d17d5537232b8339fd4 Fix issue 8257 __traits(compiles) gives compile error & v.staticfunc is a function pointer, not a delegate. Change it into (v, &typeof(v).staticfunc) https://github.com/D-Programming-Language/dmd/commit/349edf2f8fa130d49ce2361aad2ffa03f6cd55a7 Merge pull request #1194 from donc/bug8257_delegate_nonstatic 8257 x.staticfunc() is a function pointer, not a delegate -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 20 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8257 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Version|D2 |D1 & D2 Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 20 2012