[Issue 8257] __traits(compiles) gives compile error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 19 04:14:27 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8257
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug at yahoo.com.au
--- Comment #1 from Don <clugdbug at 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: -------
More information about the Digitalmars-d-bugs
mailing list