https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116158

            Bug ID: 116158
           Summary: __INTn_TYPE__ macros unexpectedly unsigned with
                    -funsigned-bitfields
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mital at mitalashok dot co.uk
  Target Milestone: ---

`__INT32_TYPE__` is currently defined as plain `int`.

When `int32_t` is defined with it (e.g., when ginclude/stdint-gcc.h is used in
freestanding mode), using it to define the type of a bit-field could become
unsigned.

For example: https://godbolt.org/z/1935T63df

```
// Compile with "-ffreestanding -funsigned-bitfields"
#include <stdint.h>

int main() {
  struct {
    int32_t bf : 1;
  } x = { -1 };
  if (x.bf != -1)
    return 1;
}
```

Exits 1.

I don't think this is non-conforming, it's just surprising. My system headers
define `int32_t` as `signed int`, meaning there is a difference between
freestanding and hosted mode.
  • [Bug c/116158] New: __INTn_TYPE... mital at mitalashok dot co.uk via Gcc-bugs

Reply via email to