[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Issues with default-initialization of bitfields

From: Petr Skocik
Subject: [Tinycc-devel] Issues with default-initialization of bitfields
Date: Fri, 4 Sep 2020 23:07:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0


I don't know if this is known, but tinycc seems to have some issues
zero-initializing bitfields.

Here's an example program:

#include <stdio.h>
#include <assert.h>
#include <stdint.h>
typedef struct TYPE TYPE;
struct TYPE { uint32_t bit:1,bits7:7,bits24:24; int32_t upper; };
int main()
    TYPE x = (TYPE){.bit=1};
    fprintf(stderr,"%u\n", x.bits7); //tends to be nonzero!
    fprintf(stderr,"%u\n", x.bits24); //tends to be nonzero!
    assert(x.upper==0); //OK
    assert(x.bits24==0); //tends to fail on tcc
    assert(x.bits7==0); //tends to fail on tcc

Petr Skocik

reply via email to

[Prev in Thread] Current Thread [Next in Thread]