Bug 7038 – Type mismatch with const struct

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-11-30T09:33:00Z
Last change time
2012-03-04T13:29:52Z
Keywords
pull
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2011-11-30T09:33:19Z
This code should be compiled: ------------------ A a; const struct A { } A b; static assert(is(typeof(a) == typeof(b))); // Error: static assert (is(A == const(A))) is false
Comment #1 by k.hara.pg — 2011-12-28T23:54:51Z
From http://d-programming-language.org/struct.html > Const and Invariant Structs > > A struct declaration can have a storage class of const, immutable or shared. > It has an equivalent effect as declaring each member of the struct as const, > immutable or shared. Then the definition of const struct A {} should translated to: struct A { const: (members...) } But, instead, current dmd implementation does like follows: struct __S { int a; int b = 2; } alias const(__S) S; -------- But, the documentation also has some inconsistent. See bug 7180.
Comment #2 by k.hara.pg — 2012-03-04T05:26:47Z
Comment #3 by github-bugzilla — 2012-03-04T11:52:33Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a1e33827c83f14004c4fd31ff665e6312ca59385 fix Issue 7038 - Type mismatch with const struct https://github.com/D-Programming-Language/dmd/commit/2e523c415a54c7f344d18898a50e9f896e4b1a15 Merge pull request #783 from 9rnsr/fix7038 Issue 7038 - Type mismatch with const struct