Bug 461 – Constant not understood to be constant when circular module dependency exists.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-10-25T20:15:00Z
Last change time
2014-02-15T13:22:16Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
digitalmars-com

Comments

Comment #0 by digitalmars-com — 2006-10-25T20:15:57Z
dmd tmp2.d tmp2b.d tmp2b.d(6): Integer constant expression expected instead of SIZE tmp2b.d(6): Integer constant expression expected instead of SIZE ----- tmp2.d ----- private import tmp2b; const int SIZE = 7; ----- tmp2b.d ----- private import tmp2; struct s { char a[ SIZE ]; } Workaround: Move constant above import of other module. ----- tmp2.d ----- const int SIZE = 7; private import tmp2b;
Comment #1 by thomas-dloop — 2006-11-08T09:36:50Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-10-26: > http://d.puremagic.com/issues/show_bug.cgi?id=461 > dmd tmp2.d tmp2b.d > tmp2b.d(6): Integer constant expression expected instead of SIZE > tmp2b.d(6): Integer constant expression expected instead of SIZE > > ----- tmp2.d ----- > > private import tmp2b; > > const int SIZE = 7; > > ----- tmp2b.d ----- > > private import tmp2; > > struct s { > > char a[ SIZE ]; > > } > > Workaround: > Move constant above import of other module. > > ----- tmp2.d ----- > > const int SIZE = 7; > > private import tmp2b; Added to DStress as http://dstress.kuehne.cn/compile/c/const_40_A.d http://dstress.kuehne.cn/compile/c/const_40_B.d http://dstress.kuehne.cn/compile/c/const_40_C.d http://dstress.kuehne.cn/compile/c/const_40_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFUfwbLK5blCcjpWoRAvQeAJ4/cIBgs3KXWqmxmsNNN2lCUhiZIQCgrbm+ nWl9Wy0Jv0MX6ivZkD3TnUk= =0Vc/ -----END PGP SIGNATURE-----
Comment #2 by r.sagitario — 2010-03-27T06:11:09Z
Semantics is not yet run on the SIZE identifier, so dmd does not know, it is const. The patch invokes semantics if not yet run. Index: optimize.c =================================================================== --- optimize.c (revision 421) +++ optimize.c (working copy) @@ -47,6 +47,8 @@ Expression *e = NULL; if (!v) return e; + if (!v->originalType && v->scope) // semantic() not yet run - BUG 461 + v->semantic (v->scope); if (v->isConst() || v->isImmutable() || v->storage_class & STCmanifest) {
Comment #3 by bugzilla — 2010-05-10T14:18:37Z
changeset 480
Comment #4 by clugdbug — 2010-05-18T12:14:42Z
Fixed DMD1.061 and DMD2.046.