[BUG] Using comma in variable declarations [FIXED]

Started by Sandman, December 08, 2008, 12:00:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sandman

Somehow this goes wrong:

#define VOID INT

import "mod_say"

Type _entry
int a;
int b;
int c;
End

Function void test(int actual, int control, string t)
Begin
if(actual==control)
say("[  OK  ] - " + t + " == " + actual + " (" + control + ")");
else
say("[FAILED] - " + t + " == " + actual + " (" + control + ")");
end
End

Process Main()
Private
_entry e1,e2;

// int i1,i2;
// int* i3,*i4; // these work
// int* i5,i6;  //

// BUG 1: something goes wrong with declaring p3 (when these lines are switched!)
_entry* p3,*p4; // Try switching these two lines: compiler error! (error: Unknown identifier ("P3"))
_entry* p1, p2; // Looks like p3 does not get declared or something

Begin

test(sizeof(_entry) ,12,"sizeof(_entry)");
test(sizeof(e1)     ,12,"sizeof(e1)");
test(sizeof(e2)     ,12,"sizeof(e2)");
test(sizeof(p1)     , 4,"sizeof(p1)");

// BUG 2: wrong size (says it's 0)
test(sizeof(p2)     ,12,"sizeof(p2)"); // 1. | not sure which of these two Bennu wants
test(sizeof(p2)     , 4,"sizeof(p2)"); // 2. | (C wants 1.)

test(sizeof(p3)     , 4,"sizeof(p3)");
test(sizeof(p4)     , 4,"sizeof(p4)");

// test(sizeof(i1)     , 4,"sizeof(i1)");
// test(sizeof(i2)     , 4,"sizeof(i2)");
// test(sizeof(i3)     , 4,"sizeof(i3)");
// test(sizeof(i4)     , 4,"sizeof(i4)");
// test(sizeof(i5)     , 4,"sizeof(i5)");
// test(sizeof(i6)     , 4,"sizeof(i6)");

End


Result:
[  OK  ] - sizeof(_entry) == 12 (12)
[  OK  ] - sizeof(e1) == 12 (12)
[  OK  ] - sizeof(e2) == 12 (12)
[  OK  ] - sizeof(p1) == 4 (4)
[FAILED] - sizeof(p2) == 0 (12)
[FAILED] - sizeof(p2) == 0 (4)
[  OK  ] - sizeof(p3) == 4 (4)
[  OK  ] - sizeof(p4) == 4 (4)

One of those FAILED's should go OK...;)

I think something goes wrong in the line:
_entry* p1, p2;
-- Sandman

SplinterGU

#1
Fixed! Thanks...


[  OK  ] - sizeof(_entry) == 12 (12)
[  OK  ] - sizeof(e1) == 12 (12)
[  OK  ] - sizeof(e2) == 12 (12)
[  OK  ] - sizeof(p1) == 4 (4)
[  OK  ] - sizeof(p2) == 12 (12)
[FAILED] - sizeof(p2) == 12 (4)
[  OK  ] - sizeof(p3) == 4 (4)
[  OK  ] - sizeof(p4) == 4 (4)


"Try switching these two lines: compiler error! (error: Unknown identifier ("P3"))"

fixed with same fix...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

Sandman

-- Sandman