www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3748] New: inout does not work properly

reply d-bugmail puremagic.com writes:
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



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: -------
Jan 28 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------

           obsolete|                            |



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: -------
Apr 26 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



*** 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: -------
Aug 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748


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

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



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: -------
Aug 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748




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: -------
Aug 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748




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: -------
Aug 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 01 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748




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: -------
Oct 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748




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: -------
Oct 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748




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: -------
Oct 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



---
*** Issue 6519 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: -------
Dec 12 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3748




---
https://github.com/D-Programming-Language/dmd/commit/39966f4f06a527ed67e6f1d6e948c9568a8745d0

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