Closed c0rp3n closed 2 years ago
while(true)
has always been a warning in SourcePawn.
stock int my_strlen(const char[] str)
{
int i = 0;
while(true)
{
if (str[i] == '\x0')
{
return i;
}
++i;
}
}
public void OnPluginStart()
{
my_strlen("");
}
SourcePawn Compiler 1.10.0.6453
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2018 AlliedModders LLC
/groups/sourcemod/upload_tmp/text7V4gn8.sp(4) : warning 206: redundant test: constant expression is non-zero
/groups/sourcemod/upload_tmp/text7V4gn8.sp(13) : warning 209: function "my_strlen" should return a value
Note that the stock has to be used for the errors to show up pre-1.11, as previously error reporting was silenced for unused stocks (this is mentioned in the 1.11 migration doc).
Ahh okay, just seems awkward when compiling with warning error, but that is fine will just use the workaround.
When writing some stocks to replace some sourcepawn natives (testing reasons) I had a while true loop which now failes to compile with the latest canges on master.
This is the code in string.inc and line 22 is
while(true)
.Whereas using a for loop with ;; works for this case.