April 10 [Issue 24495] New: ImportC: Struct initialization expression fails to initialize field | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24495 Issue ID: 24495 Summary: ImportC: Struct initialization expression fails to initialize field Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: artha@samerion.com I encountered this while working on Tree Sitter (which is C11-compliant) with ImportC: https://tree-sitter.github.io/ --- #include <stdio.h> struct Item { int a; struct { int b1; int b2; }; }; int main() { struct Item first = { .a = 1, .b1 = 2, .b2 = 3, }; struct Item second = { .a = 1, { .b1 = 2, .b2 = 3, } }; printf("first: %d, { %d, %d }\n", first.a, first.b1, first.b2); printf("second: %d, { %d, %d }\n", second.a, second.b1, second.b2); return 0; } --- $ gcc example.c && ./a.out first: 1, { 2, 3 } second: 1, { 2, 3 } $ dmd example.c && ./example first: 1, { 2, 3 } second: 1, { 2, 0 } DMD fails to initialize the second field of the inner struct if the struct is instantiated explicitly. -- |
Copyright © 1999-2021 by the D Language Foundation