[dmd-internals] [D-Programming-Language/dmd] 6ef6b7: Fixes Issue 5385 - Access must be checked for stat...

Rainer Schuetze r.sagitario at gmx.de
Fri Dec 21 13:07:25 PST 2012


On 19.12.2012 05:54, GitHub wrote:
>    Branch: refs/heads/master
>    Home:   https://github.com/D-Programming-Language/dmd
>    Commit: 6ef6b721642be8cb5a9ffbcef6f80d92fc071bc5
>        https://github.com/D-Programming-Language/dmd/commit/6ef6b721642be8cb5a9ffbcef6f80d92fc071bc5
>    Author: Andrej Mitrovic <andrej.mitrovich at gmail.com>
>    Date:   2012-12-18 (Tue, 18 Dec 2012)
>
>    Changed paths:
>      M src/mtype.c
>      A test/fail_compilation/diag5385.d
>      A test/fail_compilation/imports/fail5385.d
>
>    Log Message:
>    -----------
>    Fixes Issue 5385 - Access must be checked for static and __gshared fields.

This patch seems to have broken my precise GC implementation: it causes 
compile time type reflection to fail for private members. A stripped 
down version of the problem is:

/////////////////
module s;

struct S
{
	int x;
private:
	int p;
}

////////////////
module test;
import s;

void main()
{
     foreach(i, fieldName; (__traits(allMembers, S)))
     {
             size_t cur_offset = mixin("(S." ~ fieldName ~").offsetof");
             alias typeof(mixin("S." ~ fieldName)) U; // line 9

             pragma(msg,"  field " ~ fieldName ~ " : " ~ U.stringof);
             //mkBitmap!U(p, offset + cur_offset);
     }
}

"dmd -c test.d" now produces:
   field x : int
test.d(9): Error: struct s.S member p is not accessible
   field p : int

Interestingly, getting offsetof doesn't cause problems (but that is 
probably a bug). I understand that private members should not be 
accessible, but it also makes generating runtime type information for 
RTInfo!T difficult.

Or maybe I am missing another way to get the type of a field?



More information about the dmd-internals mailing list