🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #82

bitwise logical operations on pointers

#82
From: Ramon Pantin
Date: Fri, 24 Jul 1992 04:39
30 lines
1429 bytes
Somewhere along the evolution of C this type of expressions where made illegal:
	char	*p = ...;
	p &= ~1;

the workaround:
	p = (char *) ((int)p & ~1);

makes my code:
	- harder to write
	- less portable because it assumes that there is an integral type
	  (if not "int", "long") that has enough precision (bits) so that
	  the casts will be harmless.

I understand that (in theory) any code that does bitwise logical
operations (|, &, ~, etc.) is not portable because it is somehow interpreting
the representation of the pointer while doing such manipulations.  In practice,
for the type of work that I do (writing operating systems) and for the class
of machines that I'm interested in (machines with large flat virtual
address spaces)
I don't need to worry about machines with bizare addressing machanisms.

Could the people in the ANSI C++ committe consider allowing these traditional
K&R expressions back into the ANSI C++ language?

Do I have to write a _proposal_ for this?

Does anybody know what was the rationale for making these expressions illegal
in ANSI-C ?

Ramon Pantin 
Technical Details
Message-ID: <2113@devnull.mpd.tandem.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!devnull!seiko.mpd.tandem.com!rgp

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!devnull!seiko.mpd.tandem.com!rgp
From: rgp@seiko.mpd.tandem.com (Ramon Pantin)
Newsgroups: comp.std.c++
Subject: bitwise logical operations on pointers
Message-ID: <2113@devnull.mpd.tandem.com>
Date: 24 Jul 92 04:39:46 GMT
Sender: news@devnull.mpd.tandem.com
Lines: 33