www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5132] New: ~ unary operator silently different from C

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5132

           Summary: ~ unary operator silently different from C
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ellery-newcomer utulsa.edu


--- Comment #0 from Ellery Newcomer <ellery-newcomer utulsa.edu> 2010-10-29
12:16:39 PDT ---
~ <type> => <type> for all integer types in D, however
~ <type> => int for small integer types in C.

This is a source of silently different behavior between D and C at least in
unsigned integer types.

example:

// test.d
import std.stdio;
void main(){
  ushort x = 0xffff;
  writefln("%08x", ~x+1u);
}


// test.c
#include <stdio.h>
void main(void){
  unsigned short x = 0xffff;
  printf("%08x", ~x+1u);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 29 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5132


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2012-01-19
21:21:36 PST ---
Documented the difference.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 19 2012