www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5672] New: Internal error: ..\ztc\cod2.c 461

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

           Summary: Internal error: ..\ztc\cod2.c 461
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: spam extrawurst.org


--- Comment #0 from Stephan Dilly <spam extrawurst.org> 2011-03-01 06:12:32 PST
---
enum Foo : ulong //remove the :ulong and the internal error is gone
{
    baa = 0B_001,
}

void bitfieldToStrings(T)(T _val)
{    
    string[] res;

    foreach(mem; __traits(allMembers, T))    
    {        
        if( (_val & 1) == 1 )
        {
            res ~= "foo";
        }
    }
}

void main(string[] argv)
{
    Foo bar;

    bitfieldToStrings(bar);
}


Just happens when compiled with : dmd main.d -O
Tested with dmd 2.051 and 2.052

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5672


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
            Version|D2                          |D1 & D2
            Summary|Internal error:             |ICE(cod2.c): if ((long &1)
                   |..\ztc\cod2.c 461           |== 1) with -O


--- Comment #1 from Don <clugdbug yahoo.com.au> 2011-03-01 07:38:38 PST ---
Reduced test case:

void foo5672() {}

void bug5672(long v)
{    
    if( (v & 1) == 1 )
    {
        foo5672();
    }
}


Prehistoric bug. Same ICE on DMD 0.140.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5672


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE(cod2.c): if ((long &1)  |ICE(cod2.c): incorrect
                   |== 1) with -O               |optimization of (long &1)
                   |                            |== 1


--- Comment #2 from Don <clugdbug yahoo.com.au> 2011-03-01 17:06:17 PST ---
Completely reduced test case:
----
bool bug5672(long v)
{    
    return  (v & 1) == 1;
}
----
It's happening because in cgelem.c, elcmp(), around line 3350, 
  bool  = (long & 1) == 1; 
gets optimized into 
  bool = long & 1;
Setting the new size of the long expression isn't done correctly.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5672


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2011-03-02
14:57:52 PST ---
https://github.com/D-Programming-Language/dmd/commit/25273526365dcacb1b8e1631f14fa6a5cb62f44e

https://github.com/D-Programming-Language/dmd/commit/564995faab54f9aae525c87d9bf41d12f98cccc2

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