This is the mail archive of the gcc@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] | |
Hi,
PR c/6346, middle-end/7018 and target/9620 deal with long long bit-fields. I guess part of the confusion comes from the fact that the C standard doesn't specify how they should behave (at least I couldn't find it). So what is the following program supposed to print?
#include <stdio.h>
int main(int argc, char *argv[]){ struct { unsigned long long ull31a: 31; unsigned long long ull31b: 31; } x; x.ull31a = -1; x.ull31b = 1;
printf("%016llx %016llx %016llx\n", (x.ull31a << 48) >> 48, (x.ull31a << 16), (x.ull31b << 48)); }
Candidates are:
ffffffffffffffff ffffffffffff0000 0000000000010000 (gcc)
Correct (the integer promotions promote an unsigned integer bit-field to a signed integer, if it fits).
ffffffffffffffff 00007fffffff0000 0001000000000000 (Compaq C)
000000000000ffff 00007fffffff0000 0001000000000000 (g++) 0000000000000000 ffffffffffff0000 0000000000000000 (Compaq C++)
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |