Skip to content

UB58

definition⚓︎

A structure or union is defined without any named members (including those specified indirectly via anonymous structures and unions) .

一个结构或联合的定义没有任何命名的成员。

description⚓︎

标准中并没有相关问题的详细解释,就我个人理解,这是一个无意义,但究竟是出于怎样的考虑将它设置为 undefined behavior 有待进一步补充。

code⚓︎

#include<stdio.h>

struct A {};    //undefined behavior

int main(){

    printf("%d", sizeof(struct A));

    return 0;
}