www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5826] New: Error: Statement SwitchErrorStatement::toCBuffer() cannot be interpreted at compile time

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

           Summary: Error: Statement SwitchErrorStatement::toCBuffer()
                    cannot be interpreted at compile time
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ibuclaw ubuntu.com



From fail_compilation/fail146.d:

int bar(int i)
{
    switch (i)
    {
        case 1:
            i = 4;
            break;
        case 8:
            i = 3;
            break;
    }
    return i;
}

void main()
{
    static b = bar(7);
    printf("b = %d, %d\n", b, bar(7));
    assert(b == 3);
}



Error message:
fail_compilation/fail146.d(4): Error: no default or case for 7 in switch
statement
fail_compilation/fail146.d(4): Error: Statement
SwitchErrorStatement::toCBuffer()
 cannot be interpreted at compile time
fail_compilation/fail146.d(18): Error: cannot evaluate bar(7) at compile time
fail_compilation/fail146.d(18): Error: cannot evaluate bar(7) at compile time
fail_compilation/fail146.d(19): Error: 'printf' is not defined, perhaps you
need to import core.stdc.stdio; ?


For all intent and purposes, this line:

fail_compilation/fail146.d(4): Error: Statement
SwitchErrorStatement::toCBuffer() cannot be interpreted at compile time

Should ideally not be emitted as an error.

Regards

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


Iain Buclaw <ibuclaw ubuntu.com> changed:

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




 From fail_compilation/fail146.d:
 
 int bar(int i)
 {
     switch (i)
     {
         case 1:
             i = 4;
             break;
         case 8:
             i = 3;
             break;
     }
     return i;
 }
 
 void main()
 {
     static b = bar(7);
     printf("b = %d, %d\n", b, bar(7));
     assert(b == 3);
 }
 
 
 
 Error message:
 fail_compilation/fail146.d(4): Error: no default or case for 7 in switch
 statement
 fail_compilation/fail146.d(4): Error: Statement
 SwitchErrorStatement::toCBuffer()
  cannot be interpreted at compile time
 fail_compilation/fail146.d(18): Error: cannot evaluate bar(7) at compile time
 fail_compilation/fail146.d(18): Error: cannot evaluate bar(7) at compile time
 fail_compilation/fail146.d(19): Error: 'printf' is not defined, perhaps you
 need to import core.stdc.stdio; ?
 
 
 For all intent and purposes, this line:
 
 fail_compilation/fail146.d(4): Error: Statement
 SwitchErrorStatement::toCBuffer() cannot be interpreted at compile time
 
 Should ideally not be emitted as an error.
 
 Regards
Error message is now: test.d:3: Error: non-final switch statement without a default is deprecated test.d:17: Error: CTFE failed because of previous errors in bar test.d:18: Error: 'printf' is not defined, perhaps you need to import core.stdc.stdio; ? Interestingly, fail146.d has been removed from the testsuite, why is this? Marking as resolved anyway... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 29 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5826


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr puremagic.com



---
I was curious, so I went to find the reason:

https://github.com/D-Programming-Language/dmd/commit/d530bf60e34bb01932d5656c6a1b392beac6e5d2

Found via looking at the history for the file:

https://github.com/D-Programming-Language/dmd/commits/master/test/fail_compilation/fail146.d

also doable through the git cli: git log test/fail_compilation/fail146.d

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