The 'Pawn Language' Forum

An embedded scripting language

 

Reply To This Topic    Back To Forum Index
 
BAILOPAN



website

Posted On 2009-08-10 22:02 -- Subject: Compiler bug, ternary operator with lvalues

The ternary operator unnecessarily demotes lvalues to rvalues. For example, this code would not work:


public Bug(c) {
new array1[20]
new array2[20]
SomeFunction(c ? array1[0] : array2[1])
}

SomeFunction(const array[]) {
}


It seems like this restriction can be lifted with the right knowledge of the compiler. For example, callers of hier13() could pass down whether they want a reference or a variable -- or hier13() could return a new iTERNARY that rvalue() would get special logic to decode. Unfortunately I don't have the time to investigate further. Original bug report:

https://bugs.alliedmods.net/show_bug.cgi?id=3931#c2
Anthony
Posted On 2009-12-29 03:51 -- Subject: RE: Compiler bug, ternary operator with lvalues

Why should that work? The function takes an array, array1[#] and array2[#] are cells.
BAILOPAN



website

Posted On 2009-12-29 14:56 -- Subject: RE: Compiler bug, ternary operator with lvalues

For the same reason this already works:

public Bug(c) {
new array[20]
SomeFunction(array[2])
}

SomeFunction(const array[]) {
}

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




- BiTBOARD version 2.5 by the BiTSHiFTERS SDC -