public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@koffie.nl>
To: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
Cc: gcc@gcc.gnu.org
Subject: Re: long long bit-fields
Date: Mon, 31 Mar 2003 08:46:00 -0000	[thread overview]
Message-ID: <3E87B155.3020408@koffie.nl> (raw)
In-Reply-To: <87of3taur5.fsf@student.uni-tuebingen.de>

Falk Hueffner wrote:
> 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)

Not correct.

> 000000000000ffff 00007fffffff0000 0001000000000000 (g++)
> 0000000000000000 ffffffffffff0000 0000000000000000 (Compaq C++)

Don't know about C++, sorry.


Segher


  reply	other threads:[~2003-03-31  5:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-30 19:14 Falk Hueffner
2003-03-31  8:46 ` Segher Boessenkool [this message]
2003-03-31  9:22   ` Falk Hueffner
2003-04-01  0:11     ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E87B155.3020408@koffie.nl \
    --to=segher@koffie.nl \
    --cc=falk.hueffner@student.uni-tuebingen.de \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).