www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11874] New: __traits(isPOD) does not check base elem of static arrays

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

           Summary: __traits(isPOD) does not check base elem of static
                    arrays
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ibuclaw ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw ubuntu.com> 2014-01-06 02:33:52 PST ---
Consider the following:

---
struct CpCtor { this(this) {} }

struct NonPod { CpCtor[4] cpctor; }

/* CpCtor defines a copy construct -> is not POD.  */
static assert(!__traits(isPOD, CpCtor));

/* NonPod has a static array of CpCtor in it field list,
   so user-defined copy semantics apply -> is not POD.  */
static assert(!__traits(isPOD, NonPod));

/* However, a static array of a non-POD type does not trigger __traits(isPOD).
   This seems contrary to the behaviour of above.  */
static assert(!__traits(isPOD, CpCtor[4]));  // fails
static assert(!__traits(isPOD, NonPod[4]));  // fails

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 06 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11874


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw ubuntu.com


--- Comment #1 from Iain Buclaw <ibuclaw ubuntu.com> 2014-01-06 02:38:38 PST ---
Note, the following examples should still pass isPOD.

---
struct Empty { }
struct POD { Empty[4]; }

static assert(__traits(isPOD, Empty));
static assert(__traits(isPOD, POD));
static assert(__traits(isPOD, Empty[4]));
static assert(__traits(isPOD, POD[4]));

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 06 2014