www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDIzNzE3XSBOZXc6IHJ1bm5hYmxlL2JpdGZpZWxkcy5j?=

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

          Issue ID: 23717
           Summary: runnable/bitfields.c:192:5: error: unknown type name
                    ‘S’; use ‘struct’ keyword to refer to the type
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

When compiling the test with `gcc -std=c11 -fsyntax-only`

runnable/bitfields.c: In function ‘boo6’:
runnable/bitfields.c:192:5: error: unknown type name ‘S’; use ‘struct’
keyword
to refer to the type
  192 |     S s;
      |     ^
      |     struct 
runnable/bitfields.c:193:6: error: request for member ‘a’ in something not a
structure or union
  193 |     s.a = 3;
      |      ^
runnable/bitfields.c:194:6: error: request for member ‘b’ in something not a
structure or union
  194 |     s.b = 1;
      |      ^
runnable/bitfields.c:195:6: error: request for member ‘a’ in something not a
structure or union
  195 |     s.a += 2;
      |      ^
runnable/bitfields.c:196:13: error: request for member ‘a’ in something not
a
structure or union
  196 |     return s.a;
      |             ^


Test case:
```
struct S6
{
    unsigned int a:2, b:2;
};

int boo6()
{
    S s;
    s.a = 3;
    s.b = 1;
    s.a += 2;
    return s.a;
}
```

--
Feb 15 2023