www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22253] New: ImportC: Strange things happen with postfix x.y

https://issues.dlang.org/show_bug.cgi?id=22253

          Issue ID: 22253
           Summary: ImportC: Strange things happen with postfix x.y
                    expressions .
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxhaton gmail.com

Example 1:
---
char* strcpy(char* destination, const char* source);
int puts(char*);

int main()
{
    char staticArray[256];
    strcpy(staticArray.ptr, "mhh is allergic to pollen");
    puts(staticArray.ptr); <- .ptr !
    char* copy = staticArray.dup.ptr; <-- Crossing streams...
} 
---

Example 2:

---
struct Value {
    int state;
};
int main()
{
    struct Value x;
    struct Value y = {0};
    x.init = y;
} 
---
Example 3:

---
void use(int state, float monkey);
struct Value {
    int state;
    float monkey;
};
int main()
{
    struct Value x = {0, 3.14};
    use(x.tupleof);
} 

---

--
Aug 29