[Issue 5862] case statement allows runtime values

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 19 07:31:24 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5862



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-06-19 07:26:37 PDT ---
I don't really know why it wouldn't be allowed, unless there's some
optimization technique that depends on it.

However:

void main()
{
    int x;
    int y;

    switch (x)
    {
        case y + 1:
            break;

        default:
    }
}

Error: variable y cannot be read at compile time
Error: case must be a string or an integral constant, not y + 1

Either runtime values are fully supported, or they are not. Some decision has
to be made for this if the compiler and TDPL don't agree with each other.
Should I open up a new thread in the NGs to discuss this?

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


More information about the Digitalmars-d-bugs mailing list