Build problem with latest git head

Iain Buclaw ibuclaw at ubuntu.com
Sat Nov 9 10:53:26 PST 2013


On 9 November 2013 18:17, Johannes Pfau <nospam at example.com> wrote:

> Am Fri, 08 Nov 2013 21:00:18 +0100
> schrieb "Timo Sintonen" <t.sintonen at luukku.com>:
>
> > Now returning to my original problem.
> >
> > I tested various loops and it seems that write to a variable is
> > not volatile even if the variable is marked shared. If I write to
> > a variable several times in a loop, all but the last write are
> > optimized out. The only write is put after the loop.
> > Read works fine now with shared.
> >
> > How can I do volatile writes?
>
> AFAICS this is a GDC bug, Iain can you have a look at this?
>
> Here's a simple test case:
> ---------------------------------------------
> struct Register
> {
>     shared size_t a;
> }
>
> Register* reg = cast(Register*)0xFFDDCCAA;
>
> void main()
> {
>      for(size_t i = 0; i < 10; i++)
>          reg.a = i;
> }
> ---------------------------------------------
>
>
> Same thing in C (working):
> ---------------------------------------------
> #include <stdlib.h>
>
> struct Register
> {
>     volatile size_t a;
> };
> typedef struct Register reg_t;
>
> reg_t* reg = (reg_t*)0xFFDDCCAA;
>
> void main()
> {
>      size_t i;
>      for(i = 0; i < 10; i++)
>          reg->a = i;
> }
>
> ---------------------------------------------
>
> Compile with
> gdc -O3 test.d -S -fdump-tree-original-raw
> gcc -O3 test.c -S -fdump-tree-original-raw
>
> Of course the code won't run but the wrong optimization is obvious in
> the generated ASM. I had a quick look at the fdump-tree-original-raw
> output but I didn't see a obvious difference between the C/D output.
>


Please raise a bug.


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20131109/19a663ce/attachment.html>


More information about the D.gnu mailing list