www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22071] New: importC: Error: struct literal is not an lvalue

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

          Issue ID: 22071
           Summary: importC: Error: struct literal is not an lvalue
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

Compound literals are lvalues in C11
"""
6.5.2.5-4
If  the  type  name  specifies  an  array  of  unknown  size,  the  size  is 
determined  by  theinitializer  list  as  specified  in  6.7.9,  and  the  type
 of  the  compound  literal  is  that  of  thecompleted array type.  Otherwise
(when the type name specifies an object type), the typeof the compound literal
is that specified by the type name.  In either case, the result is an lvalue.
"""

Reduced test:
---
struct S { int a; int b; };

void test()
{
    struct S *var = &(struct S){ 1, 2 };
}

--
Jun 22