[Issue 4342] branches that are known as not taken at compile time should not be checked

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 27 00:32:56 PDT 2012


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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug at yahoo.com.au
         Resolution|                            |INVALID


--- Comment #1 from Don <clugdbug at yahoo.com.au> 2012-09-27 00:33:34 PDT ---
This if statement is a peculiar mix of compile-time and runtime conditions.
It should be rewritten as:

void f(S...)(S args) {
    static if (args[0].length>1) {
        if (args[0][1]>='0' && args[0][1]<='9') {
            printf("bla,%d\n",args[0][1]-'0');
        }
    }
}

The enhancement is basically a request for syntax sugar in these situations:
turn "if (false)" into "static if(false)". But it's very bug prone, eg this
program would compile:
------
void main(int argc)
{
   byte x = argc;
   if (x > 1000) {
       lets_confuse_the_maintenance_programmer() *= undefined_variable;
   }
}
-----
Will not be implemented.

-- 
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