llvm / llvm/llvm-project

bool bitfield += complex gets infinite loop

Open
#163,140 6 comments 0 reactions 0 assignees View on GitHub
clang:frontend floating-point
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The following code gets an infinity loop at runtime.

```c
#include /* assert */
#include /* offsetof */
#include /* FLT_SNAN */
#include /* FLT_CMPLX */
#include /* wchar_t */
#include /* printf */
int main(void){
if(1){
struct bit2 {
unsigned int uibf : 7;
signed int sibf : 7;
bool bobf : 1;
} bits = { 1u, 1, 1 };
struct bit2 res;
res.bobf = bits.bobf += CMPLXF( 1.5f, 1.5f );
}
return 0;
}
```

Contributor guide

Open the contributing guide

Research direction

Start by compiling and running the standalone C reproducer from the issue, confirming the infinite loop and recording the compiler version and options. Trace the relevant compiler behavior for the bool bitfield compound assignment involving a complex value; done when the reproducer no longer loops and the resulting behavior is covered by a regression test.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.