Thread overview
[Issue 8624] New: CTFE: 0x6161636772 == 0x4161636772
Sep 06, 2012
Ellery Newcomer
[Issue 8624] Regression: CTFE: long comparisons completely broken
Sep 07, 2012
Don
Sep 08, 2012
Brad Roberts
Sep 08, 2012
Walter Bright
Sep 10, 2012
Walter Bright
September 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8624

           Summary: CTFE: 0x6161636772 == 0x4161636772
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            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> 2012-09-05 19:17:47 PDT ---
dmd 2.060 x64 linux.

code:

int generateHashAndValueArrays()
{
  import std.string;
  assert(H("a") != H("A"), xformat("%x == %x",  H("a"), H("A")));
  return 1;
}

enum s = (generateHashAndValueArrays());

ulong H(string str)
{
    if(str[0] == 'a') return 0x6161636772;
    return 0x4161636772;
}


fireworks:

HtmlEntities.d(4): Error: ['6','1','6','1','6','3','6','7','7','2',' ','=','=',' ','4','1','6','1','6','3','6','7','7','2'][0LU..24LU]

ehh,

HtmlEntities.d(4): Error: "6161636772 == 4161636772"

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8624


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE, wrong-code
                 CC|                            |clugdbug@yahoo.com.au
            Summary|CTFE: 0x6161636772 ==       |Regression: CTFE: long
                   |0x4161636772                |comparisons completely
                   |                            |broken
           Severity|normal                      |regression


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-09-06 23:44:46 PDT ---
This is one of the worst bugs of all time. I can't believe this slipped through
the test suite. The top 32 bits of longs is entirely ignored in CTFE == and !=
comparisons. Reduced test case:
====================
int bug8624()
{
  long  m =  0x1_0000_0000;
  assert(m != 0);
  return 1;
}
static assert(  bug8624() );
====================
It's a typo in interpret.c, which results in an implicit conversion from long
to int.
This might be worth an emergency release.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8624


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr@puremagic.com


--- Comment #2 from Brad Roberts <braddr@puremagic.com> 2012-09-07 17:41:58 PDT ---
In which version did it last work correctly?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8624


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-09-08 13:14:27 PDT ---
(In reply to comment #1)
> It's a typo in interpret.c, which results in an implicit conversion from long
> to int.
> This might be worth an emergency release.

Please post pull request, and I'll get it pulled at least.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8624



--- Comment #4 from github-bugzilla@puremagic.com 2012-09-10 01:33:07 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9a732a03c9f671a7c45a9f7dbe485a0b3489f997 Fix issue 8624 Regression: CTFE: long comparisons completely broken

An implicit narrowing cast from long to int. Catastrophic.

https://github.com/D-Programming-Language/dmd/commit/475178efa63597d6d55a074406678ab92f1075ed Merge pull request #1112 from donc/regression8624ctfe

Fix issue 8624 Regression: CTFE: long comparisons completely broken

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8624


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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