Object file questions

Timo Sintonen via D.gnu d.gnu at puremagic.com
Sun Aug 17 02:24:46 PDT 2014


On Sunday, 17 August 2014 at 07:57:15 UTC, Timo Sintonen wrote:
>
>
> This seems to work.
>

This does not work with member functions

struct uartreg {
     Volatile!int sr;
     Volatile!int dr;
     Volatile!int brr;
     Volatile!int cr1;
     Volatile!int cr2;
     Volatile!int cr3;
     Volatile!int gtpr;

     // send a byte to the uart
     void send(int t) {
       while ((sr&0x80)==0)
       {  }
       dr=t;
     }

}

In this function the fetch of sr is omitted but compare is still
made against an invalid register value. Then address of dr is
omitted and store is made from wrong register to invalid address.
So the generated code is totally invalid.

If I move this function out of the struct then it is ok.
I use -O2, not tested what it woud do without optimization.

Also if I have:
cr1=cr2=0;
I get: expression this.cr2.opAssign(0) is void and has no value


More information about the D.gnu mailing list