Autor Tema: [BUG] Using comma in variable declarations [FIXED]  (Leído 1339 veces)

Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
[BUG] Using comma in variable declarations [FIXED]
« en: Diciembre 08, 2008, 12:00:27 am »
Somehow this goes wrong:

Código: [Seleccionar]
#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:
Código: [Seleccionar]
[  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:
Código: [Seleccionar]
_entry* p1, p2;
« última modificación: Enero 17, 2010, 08:34:13 pm por Sandman »
-- Sandman

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12548
  • Karma: 370
Re: [BUG] Using comma in variable declarations
« Respuesta #1 en: Diciembre 27, 2008, 01:35:47 am »
Fixed! Thanks...

Código: [Seleccionar]
[  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...
« última modificación: Diciembre 27, 2008, 01:39:14 am por SplinterGU »
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
Re: [BUG] Using comma in variable declarations
« Respuesta #2 en: Diciembre 27, 2008, 10:58:45 am »
Great! Thanks. :)
-- Sandman