Thread overview
[Issue 461] New: Constant not understood to be constant when circular module dependency exists.
Oct 26, 2006
d-bugmail
Nov 08, 2006
Thomas Kuehne
Mar 27, 2010
Rainer Schuetze
May 10, 2010
Walter Bright
May 18, 2010
Don
October 26, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=461

           Summary: Constant not understood to be constant when circular
                    module dependency exists.
           Product: D
           Version: 0.172
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: digitalmars-com@baysmith.com


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;


-- 

November 08, 2006
d-bugmail@puremagic.com 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


March 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=461


Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |r.sagitario@gmx.de


--- Comment #2 from Rainer Schuetze <r.sagitario@gmx.de> 2010-03-27 06:11:09 PDT ---
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)
     {

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=461


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2010-05-10 14:18:37 PDT ---
changeset 480

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=461


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |FIXED


--- Comment #4 from Don <clugdbug@yahoo.com.au> 2010-05-18 12:14:42 PDT ---
Fixed DMD1.061 and DMD2.046.

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