www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8079] New: Memory corruption on stack-allocated temporary static arrays

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

           Summary: Memory corruption on stack-allocated temporary static
                    arrays
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: hsteoh quickfur.ath.cx



Code:
        import std.stdio;
        struct S {
                short[4] x;
                this(short[4] args...) {
                        x[] = args[];
                }
                bool opEquals(in S s) const {
                        for (auto i=0; i < 4; i++) {
                                if (this.x[i] != s.x[i])
                                        return false;
                        }
                        return true;
                }
        }
        void main() {
                assert(S(1,2,3,4) == S(1,2,3,4));
        }

Output: with dmd -m64, the assertion fails. Inserting writeln's show that the
elements of s in opEquals() are garbage values. Trying to print out the entire
array of this or s causes a segfault.

On dmd -m32, there is no problem.

Not sure if this is related to bug 5570.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8079




P.S. Changing the static array to int[4] for some reason makes the problem go
away. Don't know how this is relevant, but might be useful to track down the
bug in the compiler.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8079




Can no longer reproduce this bug in latest git dmd, may have been fixed?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 22 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8079


Damian Ziemba <nazriel6969 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nazriel6969 gmail.com
         Resolution|                            |FIXED



PDT ---
Seems to work with DMD 2.060 (and trunk) both with m32 and m64

http://dpaste.dzfl.pl/c6857366

I think we can close this issue as for now although I am not sure what certain
Commit fixed it.

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