Thanks, it seems to be backend dependent. More feedbacks:
On RPi 32bits (arm), tested with tcc, gcc and clang: jullien@sims4:~ $ tcc foo.c && ./a.out 50 132 a.out: foo.c:11: main: Assertion `x.bits24==0' failed. Aborted jullien@sims4:~ $ gcc foo.c && ./a.out 0 0 jullien@sims4:~ $ clang foo.c && ./a.out 0 0 On RPi 64bits (aarch64): jullien@sims64:~ $ tcc foo.c && ./a.out 0 0 On Windows x64 (tcc && cl): c:\usr\jullien\openlisp>tcc -m64 foo.c && foo 124 12234828 Assertion failed: x.bits24==0, file foo.c, line 12 c:\usr\jullien\openlisp>cl -nologo foo.c && foo foo.c 0 0 On Windows x86: c:\usr\jullien\openlisp>tcc -m32 foo.c && foo 40 16402 Assertion failed: x.bits24==0, file foo.c, line 12 Btw, you can notice that the error message differs from Linux to Windows. -----Original Message----- From: Tinycc-devel [mailto:[email protected]] On Behalf Of Petr Skocik Sent: Friday, September 04, 2020 23:07 To: [email protected] Subject: [Tinycc-devel] Issues with default-initialization of bitfields Hi. 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 } Regards, Petr Skocik _______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
