www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9775] New: Can no longer create a const Date in CTFE if the variable is explicitly typed

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

           Summary: Can no longer create a const Date in CTFE if the
                    variable is explicitly typed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg gmx.com> 2013-03-21 02:15:15
PDT ---
In 2.061, this compiled:

import std.datetime;
const Date date = Date(2012, 12, 21);
void main() {}

In 2.062 (and the current master), it gives

/usr/include/D/phobos/std/datetime.d(13542): Error: Internal Compiler Error:
CTFE literal cast(short)1
dmd: ctfeexpr.c:353: Expression* copyLiteral(Expression*): Assertion `0'
failed.
Aborted (core dumped)

It works if it's changed to

import std.datetime;
const date = Date(2012, 12, 21);
void main() {}

It also works if date is made non-const

Date date = Date(2012, 12, 21);

But it doesn't work even without const, if it's an enum

enum Date date = Date(2012, 12, 21);

though as with normal variables, if the type is not given explicitly to the
enum, it compiles just fine.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 21 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-04-01 23:54:13 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1824

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oivind.loe gmail.com


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-04-02 07:37:53 PDT ---
*** Issue 9847 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775



--- Comment #3 from github-bugzilla puremagic.com 2013-04-03 16:47:29 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/79309eb016fa7271d0477a4adf77560fa3396d6c
fix Issue 9775 - Can no longer create a const Date in CTFE if the variable is
explicitly typed

https://github.com/D-Programming-Language/dmd/commit/ab53fcc44aadd5dd108525c1bf042406cf34c51f
Merge pull request #1824 from 9rnsr/fix9775

[REG2.062] Issue 9775 - Can no longer create a const Date in CTFE if the
variable is explicitly typed

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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