llvm / llvm/llvm-project

[Clang] Bitfield result from statement-expression not integer-promoted, diverges from GCC

Open
#221,542 3 comments 0 reactions 0 assignees View on GitHub
clang:frontend confirmed diverges-from:gcc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c
#include

int main(void) {
struct { unsigned b : 3; } s;
printf("%d\n", _Generic(+({s.b;}), int:1, unsigned: 2)); // GCC 1, Clang 2
}
```

https://c.godbolt.org/z/6G7heY9W5

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the minimized C example in Clang and GCC, then investigate Clang's handling of bitfields, statement-expressions, and integer promotions. The issue is complete when the expression's _Generic result matches GCC's int classification while preserving the relevant language behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.