473,735 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
+ 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 2329
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******@NOSPA M.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******@NOSPA M.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_Keit h) 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.securityfoc us.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.securityfoc us.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
3605
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 example, consider this four-bit number: 1100 from this number I want to extract two numbers: 1000 and 100 had the four-bit number been 0101 I would want to extract 100 and 1. How should I do this? I wish I had some code to post but I don't...
6
9350
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 a checkbox with a control source named "MARK" (boolean) from customer table. I can check and uncheck individual records fine. Then I created 2 command buttons named "Select All" and "Deselect All". The Onclick property of these buttons runs code...
5
1419
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 it!). E.g. assume "a" is unsigned, but could be char, short, int or long. a = -1; or
175
8871
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 changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
2
5355
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 code below in the Web.Config file defines the authentication as forms and the aspx file required for login if the user is unauthenticated... this works well for the root level company web pages however when a user viewing the website of SubCompanyA...
6
3936
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 very first time here and I will look forward to sifting through all of the posts and answers. Thanks in advance!!! I don't get an error when using the value option...but if I switch to a Table/Query, I get the following error:
4
4140
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 test data - sorry, can't create DDL as I'm at home & can't access the server :-( TABLE 1: Application_Intermediary
2
3240
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 me, what could be the reason...and what is that chunk 37 telling about?
19
10757
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 there an existing adapter? Thanks, Daniel.
0
8964
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8786
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9466
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9327
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9253
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6747
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2740
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2190
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.