Jump to page: 1 2
Thread overview
[Issue 3748] New: inout does not work properly
Apr 26, 2011
kennytm@gmail.com
Aug 31, 2011
Kenji Hara
Aug 31, 2011
Kenji Hara
Aug 31, 2011
Kenji Hara
Oct 02, 2011
Walter Bright
Oct 06, 2011
Kenji Hara
Dec 12, 2011
Kenji Hara
Dec 12, 2011
Kenji Hara
January 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3748

           Summary: inout does not work properly
           Product: D
           Version: 2.039
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: schveiguy@yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-01-28 05:06:44 PST ---
Created an attachment (id=558)
file to test whether inout is properly implemented

inout as defined by DIP2 is not implemented properly on dmd 2.039.  Attached is a testing program that should be used to determine if inout is properly implemented.  I tried to include every subtle detail that I could on inout, but I'm not sure that I got them all.  If the compiler passes this test, inout should be ready for most uses.

Since half of the definition of inout is what *doesn't* compile, I have included multiple errors in the file.  Because of the nature of compiler errors, each error can be individually enabled or disabled using version statements, a la error1, error2, etc.

When no error statements are enabled, the program should compile correctly. There is no need to run the program, since all asserts are static.

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


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #558 is|0                           |1
           obsolete|                            |


--- Comment #1 from kennytm@gmail.com 2011-04-26 11:20:36 PDT ---
Created an attachment (id=950)
Fixed some minor syntax error.

Fixed the position of ';' on line 22.
Added back the missing is() on lines 48 and 50.

(Just a note: as of commit 48950d4ce371316184e2 (2.052) DMD still cannot
compile this file successfully.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3748


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tomash.brechko@gmail.com


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-08-31 08:07:52 PDT ---
*** Issue 4968 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3748


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2011-08-31 08:15:03 PDT ---
https://github.com/D-Programming-Language/dmd/pull/359

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3748



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2011-08-31 10:40:24 PDT ---
My patch doesn't forbid to declare inout variable outside inout function. It is treated same as const variable, even with my patch.

I think it is debatable thing.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3748



--- Comment #5 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-08-31 12:11:15 PDT ---
it is not debateable.  The issue is, when inside an inout-enabled function, all inout variables are *assignable* from other inout variables.

So for example, if you have:

inout(int) * globalvar;

inout(int)* foo(inout(int)* x)
{
   return globalvar;
}

void main()
{
   int x;
   auto y = foo(&x);
}

what type is y?  inout(T) is changed to just T in this scenario, since the constancy factor is mutable, so essentially, you now have a mutable pointer to what is treated as const as you say.

The type system *must* prevent non-local variables (i.e. variables not on the stack) from being inout.  Otherwise, you cannot make guarantees about inout.

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2011-10-01 22:10:12 PDT ---
https://github.com/D-Programming-Language/dmd/commit/07f719e5bd882b0e66e9759ed29319e2be93ef3c

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3748



--- Comment #7 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-10-05 06:31:35 PDT ---
Created an attachment (id=1035)
Corrected some errors that were previously hard to detect because inout didn't
work

uploaded a fixed version of testinout.d

error8 and error11 still compile, so this isn't completely resolved, but inout is definitely is usable.

I will open a new bug for that, as this is a single problem with inout (allowing inout variables anywhere, not just as auto variables of inout functions).

Note that Kenji stated those holes were still present.  But this is definitely a huge step forward.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3748



--- Comment #8 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-10-05 06:49:38 PDT ---
See new bug 6770

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3748



--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-05 17:41:38 PDT ---
For fixing error8 and error11. https://github.com/D-Programming-Language/dmd/pull/433

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2