[dmd-internals] OSX 64 bit

Walter Bright walter at digitalmars.com
Thu Dec 1 14:05:22 PST 2011



On 12/1/2011 12:45 AM, Don Clugston wrote:
>
> The hex digits are 4 higher than they should be, in every case.
> '0'->  '4', '2'->'6', '9' ->  'D', etc.
> The hex digits are set in this function:
>
> void toHexZeroPadded(char[] output, uint value)
> {
>      ptrdiff_t x = output.length - 1;
>      static immutable string hexDigits = "0123456789ABCDEF";
>      for( ; x>=0; --x)
>      {
>          output[x] = hexDigits[value&  0xF];
>          value>>= 4;
>      }
> }
>
> This really looks as though hexDigits is the wrong address. Maybe
> because it's a local static variable.
> I predict that a minimal test case would be:
>
> void foo(uint value)
> {
>      static immutable string hexDigits = "0123456789ABCDEF";
>      assert( hexDigits[value&  0xF] == '0');
> }
> void main()
> {
>    foo(0);
> }
> _______________________________________________
>

I tried various iterations on this and can't get a failure. Grrrr...


More information about the dmd-internals mailing list