www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 772] New: Bogus error using relation operator as static if expression within template

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

           Summary: Bogus error using relation operator as static if
                    expression within template
           Product: D
           Version: 0.178
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: ibisbasenji gmail.com


Given the following useless test program...
--------------------------------------------------
module bug ;

template foo (ulong n) {
  static if (n < 10_LU) {
    const foo = n ;
  }
  else {
    const foo = n % 10 ;
  }
}

void main () {
  ulong a = 1_LU ;

  auto omega = foo!(a);
}
--------------------------------------------------

The compiler will output:
bug.d(4): Error: expression (a) < 10LU does not evaluate to a boolean
bug.d(15): template instance bool0.main.foo!(a) error instantiating


-- 
Dec 29 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=772





------- Comment #1 from thomas-dloop kuehne.cn  2006-12-31 08:47 -------
Added to DStress as
http://dstress.kuehne.cn/compile/o/opCmp_09_A.d
http://dstress.kuehne.cn/compile/o/opCmp_09_B.d
http://dstress.kuehne.cn/nocompile/o/opCmp_09_C.d
http://dstress.kuehne.cn/run/o/opCmp_09_D.d


-- 
Dec 31 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=772


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2007-01-03 22:54 -------
Fixed DMD 1.00


-- 
Jan 03 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=772


davidl 126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Comment #3 from davidl 126.com  2008-07-24 08:57 -------
seems regression on dmd 1.033


-- 
Jul 24 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=772


gide nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID




------- Comment #4 from gide nwawudu.com  2008-11-08 12:34 -------
const should be added to the variable declaration, so the error message is
correct. Add const and it works in DMD 2.020 and 1.033.

module bug ;

template foo (ulong n) {
  static if (n < 10_LU) {
    const foo = n ;
  }
  else {
    const foo = n % 10 ;
  }
}

void main () {
  const ulong a = 1_LU ; // <- added const

  auto omega = foo!(a);
}


-- 
Nov 08 2008