home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / std / cplus / 935 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  1.4 KB

  1. Path: sparky!uunet!cs.utexas.edu!devnull!seiko.mpd.tandem.com!rgp
  2. From: rgp@seiko.mpd.tandem.com (Ramon Pantin)
  3. Newsgroups: comp.std.c++
  4. Subject: bitwise logical operations on pointers
  5. Message-ID: <2113@devnull.mpd.tandem.com>
  6. Date: 24 Jul 92 04:39:46 GMT
  7. Sender: news@devnull.mpd.tandem.com
  8. Lines: 33
  9.  
  10. Somewhere along the evolution of C this type of expressions where made illegal:
  11.     char    *p = ...;
  12.     p &= ~1;
  13.  
  14. the workaround:
  15.     p = (char *) ((int)p & ~1);
  16.  
  17. makes my code:
  18.     - harder to write
  19.     - less portable because it assumes that there is an integral type
  20.       (if not "int", "long") that has enough precision (bits) so that
  21.       the casts will be harmless.
  22.  
  23. I understand that (in theory) any code that does bitwise logical
  24. operations (|, &, ~, etc.) is not portable because it is somehow interpreting
  25. the representation of the pointer while doing such manipulations.  In practice,
  26. for the type of work that I do (writing operating systems) and for the class
  27. of machines that I'm interested in (machines with large flat virtual
  28. address spaces)
  29. I don't need to worry about machines with bizare addressing machanisms.
  30.  
  31. Could the people in the ANSI C++ committe consider allowing these traditional
  32. K&R expressions back into the ANSI C++ language?
  33.  
  34. Do I have to write a _proposal_ for this?
  35.  
  36. Does anybody know what was the rationale for making these expressions illegal
  37. in ANSI-C ?
  38.  
  39. Ramon Pantin 
  40.  
  41.  
  42.  
  43.