Skip to content

Type definitions should be allowed inside of the offsetof type #83658

@Halalaluyafail3

Description

@Halalaluyafail3

Clang does not accept type definitions inside of the type provided to offsetof. However, I don't see any wording which forbids this. Here is an example program (Clang 16 and newer don't seem to accept this):

#include<stddef.h>
int main(void){
    offsetof(struct{int a;},a);
}

There was a proposal (N2350) which added some text to make this UB, but that has been changed since by DE-137 (N3148) which removes this restriction and only makes it UB if there is an unparenthesized comma inside of offsetof. N3167 includes discussion about accepting DE-137.

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions