www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9244] New: union containing pointers not allowed

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

           Summary: union containing pointers not allowed
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rtcvb32 yahoo.com



---
Silently enters 'void* this;' pointer making compiling error out. Current beta
(v2.061, windows 32bit)

 Only by using traits will the problem show itself.

[code]
  static assert(__traits(compiles, {
    union xxx {
    int i;
    //bitfields will make such functions...
    mixin("int geti()  safe const nothrow pure {return i;}void seti(int ii)
 safe pure nothrow {i = ii;}");
    }
  }));
[/code]

output:

test.d(??): Error: static assert  (__traits(compiles,delegate pure nothrow
 safe void()
{
union xxx
{
int i;
mixin("int geti()  safe const nothrow pure {return i;}void seti(int ii)  safe
pure nothrow {i = ii;}");
void* this;
}
}
)) is false

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


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PST ---
If this is a regression, it needs to be marked as such.

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


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
         OS/Version|Windows                     |All
           Severity|normal                      |regression



Reduced:

void main()
{
    union U {
        int i;
         safe int x() { return i; }
    }
}

Because U has a function in it, dmd incorrectly decides it is a nested union
and (even worse) inserts a void* member.

A regression because:
-  safe code didn't always disallow unions with pointers
- wrapping x in an attribute such as  safe used to make the compiler infer U as
non-nested

Workaround: make U static

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 14 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9244


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



00:08:07 PST ---
https://github.com/D-Programming-Language/dmd/pull/1591

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




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0e21647a30c50e02e4a9ce43ee7e891a41d7c255
fix Issue 9244 - union containing pointers not allowed

https://github.com/D-Programming-Language/dmd/commit/95a3f5ff979f40ff0e7ae459b8d9786d64f901a7


fix Issue 9244 - union containing pointers not allowed

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2013