Bug 11874 – __traits(isPOD) does not check base elem of static arrays
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-06T02:33:00Z
Last change time
2017-04-20T08:29:06Z
Assigned to
nobody
Creator
ibuclaw
Comments
Comment #0 by ibuclaw — 2014-01-06T02:33:52Z
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
Comment #1 by ibuclaw — 2014-01-06T02:38:38Z
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]));