https://bugs.llvm.org/show_bug.cgi?id=37295
Bug ID: 37295
Summary: union with zero length array cause compile warning
Product: new-bugs
Version: 3.9
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: ykro...@gmail.com
CC: llvm-bugs@lists.llvm.org
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct FooT
{
uint32_t type;
uint32_t len;
union
{
uint8_t array[0];
} u;
FooT() {
}
} FooT;
#ifdef __cplusplus
}
#endif
int main(int argc, const char *argv[])
{
printf("sizeof FooT %zd\n", sizeof(FooT));
return 0;
}
-----
Compile above code snippet will warns:
main.cpp:14:5: warning: union has size 0 in C, size 1 in C++
[-Wextern-c-compat]
union
But the runtime result shows sizeof(FooT) is 8:
sizeof FooT 8
Seems like introduce by https://bugs.llvm.org/show_bug.cgi?id=5065
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs