473,480 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can "all bits zero" be a trap representation for integral types?

Reliable sources (whose names I'm not allowed to disclose) told me that on
the next version of the Deathstation (version 10000, or DS10K) an integral
type (they didn't tell which) will have a odd parity bit, that is a bit
which is set if an even number of value/sign bits are set, and unset
otherwise. If the parity is wrong, the representation is a trap, and they
didn't tell me how it is handled (and they won't even have to tell this
when they release the DS10K, as it is UB). Of course, "all bits zero" will
be a trap representation, so I won't be able to port there code which
assumes that memory allocated with calloc(size) or erased with
memset(array, 0, size) can be used as an array of integers which has been
initialized to {0}. Will they still be allowed to claim that their
platform conforms to the ISO standard? Footnote 44 in 6.2.6.2 makes me
fear they will.

--
Army1987
(Replace "NOSPAM" with "email")

Jul 6 '07 #1
6 2298
Army1987 wrote:
Reliable sources (whose names I'm not allowed to disclose) told me that on
the next version of the Deathstation (version 10000, or DS10K) an integral
type (they didn't tell which) will have a odd parity bit, that is a bit
which is set if an even number of value/sign bits are set, and unset
otherwise. If the parity is wrong, the representation is a trap, and they
didn't tell me how it is handled (and they won't even have to tell this
when they release the DS10K, as it is UB). Of course, "all bits zero" will
be a trap representation, so I won't be able to port there code which
assumes that memory allocated with calloc(size) or erased with
memset(array, 0, size) can be used as an array of integers which has been
initialized to {0}. Will they still be allowed to claim that their
platform conforms to the ISO standard? Footnote 44 in 6.2.6.2 makes me
fear they will.
The current ISO standard is C99+TC1+TC2, and TC2 added a requirement that
all bits zero be a valid representation for zero for all integer types. See
DR #263 <http://open-std.org/jtc1/sc22/wg14/www/docs/dr_263.htm>
Jul 6 '07 #2
In article <pa****************************@NOSPAM.it>,
Army1987 <ar******@NOSPAM.itwrote:
>Reliable sources (whose names I'm not allowed to disclose) told me that on
the next version of the Deathstation (version 10000, or DS10K) an integral
type (they didn't tell which) will have a odd parity bit, that is a bit
which is set if an even number of value/sign bits are set, and unset
otherwise. If the parity is wrong, the representation is a trap, and they
didn't tell me how it is handled (and they won't even have to tell this
when they release the DS10K, as it is UB). Of course, "all bits zero" will
be a trap representation, so I won't be able to port there code which
assumes that memory allocated with calloc(size) or erased with
memset(array, 0, size) can be used as an array of integers which has been
initialized to {0}. Will they still be allowed to claim that their
platform conforms to the ISO standard? Footnote 44 in 6.2.6.2 makes me
fear they will.
I believe that as long as the integral type they're talking about isn't
unsigned char, they will.
dave
(others will be sure to correct me if I'm wrong.)

--
Dave Vandervies dj******@csclub.uwaterloo.ca
Actually, anything false posted here tends to get corrected pretty quickly.
Actually, anything posted here tends to get corrected pretty quickly.
--Ben Pfaff and Joe Wright in comp.lang.c
Jul 6 '07 #3
Army1987 <ar******@NOSPAM.itwrites:
Reliable sources (whose names I'm not allowed to disclose) told me that on
the next version of the Deathstation (version 10000, or DS10K) an integral
type (they didn't tell which) will have a odd parity bit, that is a bit
which is set if an even number of value/sign bits are set, and unset
otherwise. If the parity is wrong, the representation is a trap, and they
didn't tell me how it is handled (and they won't even have to tell this
when they release the DS10K, as it is UB). Of course, "all bits zero" will
be a trap representation, so I won't be able to port there code which
assumes that memory allocated with calloc(size) or erased with
memset(array, 0, size) can be used as an array of integers which has been
initialized to {0}. Will they still be allowed to claim that their
platform conforms to the ISO standard? Footnote 44 in 6.2.6.2 makes me
fear they will.
n1124 6.2.6.2p5 says;

For any integer type, the object representation where all the bits
are zero shall be a representation of the value zero in that type.

This wording does not appear in the original C99 standard; it was
added by TC2, in response to Defect Report # 263,
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_263.htm>.

Whether the DS9K or DS10K's C compiler conforms to n1124 or merely to
C99 is another question.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 6 '07 #4
Harald van D?k wrote:
>
.... snip ...
>
The current ISO standard is C99+TC1+TC2, and TC2 added a
requirement that all bits zero be a valid representation for zero
for all integer types. See DR #263
<http://open-std.org/jtc1/sc22/wg14/www/docs/dr_263.htm>
As I understand it that was added only after research showed that
no existing compiler systems would be affected by the added
requirement.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 6 '07 #5
On Fri, 06 Jul 2007 16:59:45 -0400, CBFalconer wrote:
Harald van D?k wrote:
>>
... snip ...
>>
The current ISO standard is C99+TC1+TC2, and TC2 added a
requirement that all bits zero be a valid representation for zero
for all integer types. See DR #263
<http://open-std.org/jtc1/sc22/wg14/www/docs/dr_263.htm>

As I understand it that was added only after research showed that
no existing compiler systems would be affected by the added
requirement.
I had already read in the Rationale that the Committee did not
know of any machines with user-accessible parity bits within an
integer. But I also read that padding bits were added in C99. I
can't see why they didn't just disallow that thing, by simplily
requiring padding bits to be ignored. (Did any member of the
Committee work for ART, the makers of the DS9K?)
Jul 7 '07 #6
Army1987 wrote:
CBFalconer wrote:
>Harald van D?k wrote:
>>>
... snip ...
>>>
The current ISO standard is C99+TC1+TC2, and TC2 added a
requirement that all bits zero be a valid representation for zero
for all integer types. See DR #263
<http://open-std.org/jtc1/sc22/wg14/www/docs/dr_263.htm>

As I understand it that was added only after research showed that
no existing compiler systems would be affected by the added
requirement.

I had already read in the Rationale that the Committee did not
know of any machines with user-accessible parity bits within an
integer. But I also read that padding bits were added in C99. I
can't see why they didn't just disallow that thing, by simplily
requiring padding bits to be ignored. (Did any member of the
Committee work for ART, the makers of the DS9K?)
Padding has been around since 1 BC, and has always been ignored.
Such bits are intended to detect use of uninitialized, or
erroneous, values. Some can be seen by an unsigned char access.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 7 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3578
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
6
9300
by: GSteven | last post by:
(as formerly posted to microsoft.public.access.forms with no result) I've created a continuous form which is based on a straightforward table (ex - customers - 100 records). On the form there is...
5
1403
by: John Devereux | last post by:
I was wondering what is the "best" way to set a variable to "all ones". In particular where I do not know the precise type of the variable (or more accurately, when I don't want to worry about...
175
8638
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
2
5340
by: Murphy | last post by:
Our website contains subdirectories for each subsidiary company, each company has it's own look and feel to the pages in their subdirectory although they are all part of the main website. The...
6
3914
by: Mark | last post by:
I first read about this in mvps.org, but the code he gives doesn't seem to work for my form. I"ll post my code below. I'd love it if someone could point out the error in my code. BTW, this is my...
4
4127
by: google | last post by:
Hi Hope someone can help me with this - have been staring at this problem all day, and with the cold I've got, just don't seem to be able to figure it out! I've got two tables, here with some...
2
3223
by: muslimak | last post by:
I have a perl script that throws an error "illegal division by zero" chunk 37. FYI, this script was the one that worked fine two days back. There is no change in the script. Can anyone tell...
19
10722
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7010
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3011
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.