The 'Pawn Language' Forum

An embedded scripting language

 

Reply To This Topic    Back To Forum Index
 
incrediball
Posted On 2009-08-13 18:21 -- Subject: Char operator broken?

The following program causes the Pawn compiler to crash:

#include string

static strcells (const string[])
{
return (strlen(string) + 1) char
}

main()
{
return strcells (!"test")
}

The compiler outputs:
Assertion Failed: match_length>=repl_length, function stgopt, file sc7.c, line 710.
ABNORMAL TERMINATION
Pawn compiler 3.3.4127 ... Copyright...
Failure; return code 255

Removing the "char" operator in strcells allows the program to compile. It seems that the char operator works on constants but causes this crash when used on variables.
Anthony
Posted On 2009-12-29 03:54 -- Subject: RE: Char operator broken?

I'm not exactly sure what you are trying to do. I know that in the implimentation of Pawn I am used to, there is a String type (UTF-8). In this implimentation, you can cast any cell type like this:
new String:gaben[]="Gaben";
new character=_:gaben[2];

Again, no idea what you are really asking, sorry.
incrediball
Posted On 2010-01-10 19:54 -- Subject: RE: Char operator broken?

"char" is an operator that calculates the number of cells needed to store a given number of packed characters. For example the declarations:

new buf[20 char]

and

new buf[17 char]

Both create an array of 5 cells, which are both capable of holding 20 byte sized characters (including the terminating null).

However I found that if the char operator is applied to a variable, the compiler crashes in the peephole optimizer. In my example strcells is used to calculate the number of cells required for storing a packed string but because the string length is a variable, it crashes.

You Are On Page: 1/1 <<   <   1   >   >>




- BiTBOARD version 2.5 by the BiTSHiFTERS SDC -