www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Bug 84] New: Writes to struct members marked as shared are not


             Bug #: 84
           Summary: Writes to struct members marked as shared are not
    Classification: Unclassified
           Product: GDC
           Version: development
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gdc
        AssignedTo: ibuclaw gdcproject.org
        ReportedBy: johannespfau gmail.com

As originally reported by Timo Sintonen in the D.gnu newsgroup, see
http://forum.dlang.org/thread/cbdjfujryokvvwvetyuj forum.dlang.org#post-tzakpzaooenwrkpdbxgw:40forum.dlang.org

Test case in D
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 test case 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
gcc -O3 test.c -S

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.

Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
Nov 09 2013