Open
Description
Bugzilla Link | 24711 |
Version | trunk |
OS | Linux |
CC | @DougGregor |
Extended Description
Consider the following code:
/*** test.c ***/
#include <stdio.h>
struct S {
char tmp[0];
};
struct T {
struct S v01;
struct S v02;
};
int main(void) {
printf("%lu\n", sizeof(struct S));
printf("%lu\n", sizeof(struct T));
return 0;
}
/*****/
If you compile this as a .c file on x64 linux targeting x64 linux, using -Wc++-compat, you get the following warnings:
test.c:3:1: warning: struct has size 0 in C, size 1 in C++ [-Wc++-compat]
struct S {
^
test.c:7:1: warning: struct has size 0 in C, non-zero size in C++ [-Wc++-compat]
struct T {
^
But if rename the file to be .cpp and recompile, you find that both of those warnings are not true. The size of both S and T are reported to be 0, which does at least seem to be consistent with what gcc produces.