From 6243542778159478890
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,21918306fa4a8c23
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-07-27 02:34:01 PST
Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!212.74.64.35!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Marvin Sielenkemper <sielenk@gmx.de>
Newsgroups: comp.std.c++
Subject: Re: Defect Report: Integral promotions on bit-fields
Date: Fri, 27 Jul 2001 09:33:11 GMT
Organization: MaSiTec Inc.
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3B6109B7.3CDEB307@gmx.de>
References: <873f7ae8.0107240636.17de088b@posting.google.com>
X-Trace: mail2news.demon.co.uk 996226397 mail2news:4806 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Orig-NNTP-Posting-Host: b47b5.pppool.de (213.7.71.181)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Orig-X-Trace: fu-berlin.de 996215343 1190973 213.7.71.181 (16 [99384])
X-Orig-Path: wonko.masitec.de!nobody
X-Accept-Language: de-DE, de, en
Lines: 52
Xref: archiver1.google.com comp.std.c++:6766

Kiril Avdeiv wrote:
> 
> [ Forwarded to C++ Committeee. -sdc ]
> 
> Paragraph 3 of section 4.5 [conv.prom] contains a statement saying
> that if a bit-field is larger than int or unsigned int, no integral
> promotions apply to it. This phrase needs further clarification, as it
> is hardly possible to fugure out what it means. See below.
> 
> Assuming a machine with a size of general-purpose register equal 32
> bits (where a byte takes up 8 bits) and a C++ implementation where an
> int is 32 bits and a long is 64 bits. And the following snippet of
> code:
> 
> struct ExternalInterface {
>   long field1:36, field2:28;
> };
> 
> int main() {
>   ExternalInterface  myinstance = { 0x100000001L, 0x12,};
>   if(myinstance.field1 < 0x100000002L) { //do something }
> }
> 
> Does the standard prohibit the implementation from promoting field1's
> value into two general purpose registers? [...]

The standard doesn't have a notion of 'general purpose register'.
But I understand the problem.
There is an integral conversion defined (4.7-3) for this case.
It's just not called integral promotion because long int values are
deliberately (see below) omitted in 4.5.

IMO, 'integral promotion' is defined by the standard, because most 
implementations are based on some kind of register machine and the
type int is supposed to reflect the register 'type'.
An integral promotion can thus be implemented as the atomic action of
loading a register.

Operations on long int values may be far more complex, they might even
invoke calls to runtime support functions.
The machine stated above might have only one accumulator register of
32 bits ...


Marvin H. Sielenkemper

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]



