Re: [Vala] Pre Increment



* Clément DAVID <c david86 gmail com> wrote:
Vala make a wrong translation to C of:

public class PreInc {
    public static int main(string[] args)
    {
        int i=0;
        int m = 5;
        do {
            stdout.printf("%d\n",i);
        }while(++i < m);
    }
}

for the while the C generated code is :

 do {
                fprintf (stdout, "%d\n", i);
        } while (i = i + 1 < m);

in this case the program finished by a Segmentation Fault. Whereas in
"while( ++i < m);" the program works

Looks like Vala forgets to put braces around the statement.

Yours,
-- 
 Ed Schouten <ed fxq nl>
 WWW: http://g-rave.nl/

Attachment: pgp175Tm8nS5A.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]