paulsemel added a comment.

First thanks all for reviewing !

Basically, what's happening is that it works good with non-packed structures.
Here is an example for packed structure (with unsigned signed short):

  c
  struct lol {
        unsigned short a:3;
        unsigned short b:2;
        unsigned short c:6;
        unsigned short d:2;
        unsigned short e:6;
  } __attribute__((packed));
  
  int main(void)
  {
        struct lol lolo = {
                .a = 2,
                .b = 1,
                .c = 13,
                .d = 2,
                .e = 9
        };
        __builtin_dump_struct(&lolo, &printf);
        return 0;
  }

Here is the output I get :

  sh
  unsigned short a : 2
  unsigned short b : 1
  unsigned short c : 13
  unsigned short d : 2
  unsigned short e : 1

The last `unsigned short` is incorrect.

If I switch this to signed integers, I get :

  sh
  unsigned short a : 0
  unsigned short b : 0
  unsigned short c : 0
  unsigned short d : 0
  unsigned short e : 0

All the fields are zeroed. I absolutely do not understand what is happening...
Thanks for trying to help guys !


Repository:
  rC Clang

https://reviews.llvm.org/D47953



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to