<div dir="ltr">2012/12/22 Rainer Schuetze <span dir="ltr"><<a href="mailto:r.sagitario@gmx.de" target="_blank">r.sagitario@gmx.de</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 19.12.2012 05:54, GitHub wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
   Branch: refs/heads/master<br>
   Home:   <a href="https://github.com/D-Programming-Language/dmd" target="_blank">https://github.com/D-<u></u>Programming-Language/dmd</a><br>
   Commit: 6ef6b721642be8cb5a9ffbcef6f80d<u></u>92fc071bc5<br>
       <a href="https://github.com/D-Programming-Language/dmd/commit/6ef6b721642be8cb5a9ffbcef6f80d92fc071bc5" target="_blank">https://github.com/D-<u></u>Programming-Language/dmd/<u></u>commit/<u></u>6ef6b721642be8cb5a9ffbcef6f80d<u></u>92fc071bc5</a><br>

   Author: Andrej Mitrovic <<a href="mailto:andrej.mitrovich@gmail.com" target="_blank">andrej.mitrovich@gmail.com</a>><br>
   Date:   2012-12-18 (Tue, 18 Dec 2012)<br>
<br>
   Changed paths:<br>
     M src/mtype.c<br>
     A test/fail_compilation/<u></u>diag5385.d<br>
     A test/fail_compilation/imports/<u></u>fail5385.d<br>
<br>
   Log Message:<br>
   -----------<br>
   Fixes Issue 5385 - Access must be checked for static and __gshared fields.<br>
</blockquote>
<br></div>
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:<br>
<br>
/////////////////<br>
module s;<br>
<br>
struct S<br>
{<br>
        int x;<br>
private:<br>
        int p;<br>
}<br>
<br>
////////////////<br>
module test;<br>
import s;<br>
<br>
void main()<br>
{<br>
    foreach(i, fieldName; (__traits(allMembers, S)))<br>
    {<br>
            size_t cur_offset = mixin("(S." ~ fieldName ~").offsetof");<br>
            alias typeof(mixin("S." ~ fieldName)) U; // line 9<br>
<br>
            pragma(msg,"  field " ~ fieldName ~ " : " ~ U.stringof);<br>
            //mkBitmap!U(p, offset + cur_offset);<br>
    }<br>
}<br>
<br>
"dmd -c test.d" now produces:<br>
  field x : int<br>
test.d(9): Error: struct s.S member p is not accessible<br>
  field p : int<br></blockquote><div><br></div><div style>Hmm..., this is interesting issue which could be debetable.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Interestingly, getting offsetof doesn't cause problems (but that is probably a bug).</blockquote><div><br></div><div style><div>In the expression (S.field).offsetof, the part (S.field) is parsed as *a type*. And current dmd implemtation does not run access check in the resolving of dot-chained type identifier.</div>
<div style>If you changed it to S.field.offsetof, access check will report an error.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I understand that private members should not be accessible, but it also makes generating runtime type information for RTInfo!T difficult.<br>
<br>
Or maybe I am missing another way to get the type of a field?<br></blockquote><div><br></div><div style>Using tupleof can be a workaround.</div><div style><br></div><div style>Kenji Hara</div></div></div></div>