www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5291] New: ref parameter and const/immutable == hole in const system

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

           Summary: ref parameter and const/immutable == hole in const
                    system
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras gmail.com> 2010-11-29 18:07:18
PST ---
Can't believe nobody has noticed this before:

void bar( ref int n ) {
    n++;
}

void main( string[] args ) {
    const int n = args.length * 0;
    assert( is( typeof( n ) == const(int) ) );
    bar( n ); // Uhm...
    assert( n == 1 ); // WTF?!?
}

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2010-11-29
18:29:09 PST ---
immutable bug example:

bug.d:
void bar( ref int n )
{
       n++;
}

void main( string[] args )
{
       immutable int n = args.length * 0;
       assert( is( typeof( n ) == const(int) ) );
       bar( n ); // Uhm...
       assert( n == 1 );
}

compiled with "dmd bug.d"
core.exception.AssertError bug(11): Assertion failure

compiled with "dmd bug.d -release -O -inline"
object.Error: assert(0) or HLT instruction

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



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2010-11-29
18:30:13 PST ---
(In reply to comment #1)
 immutable bug example:
 
 bug.d:
 void bar( ref int n )
 {
        n++;
 }
 
 void main( string[] args )
 {
        immutable int n = args.length * 0;
        assert( is( typeof( n ) == const(int) ) );
        bar( n ); // Uhm...
        assert( n == 1 );
 }
 
 compiled with "dmd bug.d"
 core.exception.AssertError bug(11): Assertion failure
 
 compiled with "dmd bug.d -release -O -inline"
 object.Error: assert(0) or HLT instruction
My bad I forgot about the first assert. Sorry! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 29 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5291


nfxjfg gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg gmail.com


--- Comment #3 from nfxjfg gmail.com 2010-11-30 01:01:24 PST ---
This is actually well known. See bug 2095 or bug 4251.
I can't believe it hasn't been fixed yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 30 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5291


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |DUPLICATE


--- Comment #4 from yebblies <yebblies gmail.com> 2011-01-26 18:27:18 PST ---
*** This issue has been marked as a duplicate of issue 5493 ***

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