www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4241] New: duplicate union initialization error doesn't give a file location

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

           Summary: duplicate union initialization error doesn't give a
                    file location
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: mrmocool gmx.de



import std.typetuple;

/// repeat a type count times
template Repeat(T, int count)
{
    static if (!count)
        alias TypeTuple!() Repeat;
    else
        alias TypeTuple!(T, Repeat!(T, count-1)) Repeat;
}

struct Vector(T, int dim)
{
    static assert (dim >= 2 && dim <= 4);

    union
    {
// including these gives more errors of the same kind
//        T[dim] cell;            /// array access
//        Repeat!(T, dim) tuple;    /// for tuple access

        /// normal struct element access
        struct
        {
            static if (dim >= 1)    union { T x; T r; }
            static if (dim >= 2)    union { T y; T g; }
            static if (dim >= 3)    union { T z; T b; }
            static if (dim >= 4)    union { T w; T a; }
        }
    }

    // these constructors are workarounds for the "overlapping initialization
for _tuple_field_0" problem
    static if (dim == 2)
    this(T ax, T ay)
    {
        x = ax;
        y = ay;
    }

    static if (dim == 3)
    this(T ax, T ay, T az)
    {
        x = ax;
        y = ay;
        z = az;
    }

    static if (dim == 4)
    this(T ax, T ay, T az, T aw)
    {
        x = ax;
        y = ay;
        z = az;
        w = aw;
    }

    static if (2 == dim) const static Vector zero = Vector(0, 0);
    static if (3 == dim) const static Vector zero = Vector(0, 0, 0);
    static if (4 == dim) const static Vector zero = Vector(0, 0, 0, 0);
}

alias Vector!(float, 2)    Vector2f; ///
alias Vector!(float, 3)    Vector3f; ///
alias Vector!(float, 4)    Vector4f; ///

yields:
Error: duplicate union initialization for r
Error: duplicate union initialization for g
Error: duplicate union initialization for r
Error: duplicate union initialization for g
Error: duplicate union initialization for b
Error: duplicate union initialization for r
Error: duplicate union initialization for g
Error: duplicate union initialization for b
Error: duplicate union initialization for a


It would be helpful to have a file location.
Unfortunately for some reason loc is null in StructLiteralExp::toDt(dt_t **pdt)
where the error occurs.

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


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras gmail.com



PDT ---
Reduced test case:

import std.typetuple;

struct bar( int n, T ) {
    static immutable bar b = bar( 0 );

    Tuple!( int ) fields;

    this( int arg ) {
       fields.field[0] = arg;
    }
}

alias bar!( 3, int ) b;

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


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
            Version|2.041                       |D1 & D2
         OS/Version|Windows                     |All
           Severity|normal                      |critical



https://github.com/D-Programming-Language/dmd/pull/677

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


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|nobody puremagic.com        |yebblies gmail.com



https://github.com/D-Programming-Language/dmd/pull/677

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




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

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


Issue 4241 - duplicate union initialization error doesn't give a file location

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




Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a933ce10cc15d2eb6b54a7d00b6f416d1ada6097
fix Issue 4241 - duplicate union initialization error doesn't give a file
location

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


Walter Bright <bugzilla digitalmars.com> changed:

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


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