This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/41793] [4.3/4.4/4.5 Regression] About Long long bit field



------- Comment #7 from shenrfen at gmail dot com  2009-10-23 01:52 -------
What about the following case? There is not un-defined behavior.  
PS :Could you please tell me the full name of DR #120 documents.
Thanks again.

struct s
{
        unsigned long long a:2;
        unsigned long long b:40;
        unsigned long long c:22;
};

int main()
{
        struct s t = {1, 2, 3};
        unsigned long long a = t.a - 8;
        unsigned long long b = t.b - 8;
        unsigned long long c = t.c - 8;

        printf("0x%llx\n",a);
        printf("0x%llx\n",b);
        printf("0x%llx\n",c);
}

Tht output is :
0xfffffffffffffff9
0xfffffffffa
0xfffffffffffffffb


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41793


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]