I found a problem using our code in combination with CG Tools 7.3.4. The program is running on a C6455 DSP.
This is an example:
#include <string.h>
#include <ctype.h>
void test(const char *pText, char *pTextOut)
{
static char BadChars[] = "*?<>|\"+=,:;\\[]";
int i, j;
memset(pTextOut, ' ', 20);
i = j = 0;
while (pText[i] != '.')
{
if ((strchr(BadChars, pText[i]) == 0) && (pText[i]>=' '))
{
pTextOut[j] = toupper(pText[i]);
j++;
}
i++;
}
j = 0;
i++;
while ((pText[i] != '\0') && (j<3))
{
if ((strchr(BadChars, pText[i]) == 0) && (pText[i]>=' '))
{
pTextOut[j+8] = toupper(pText[i]);
j++;
}
i++;
}
pTextOut[11] = '\0';
}
int main(void)
{
char textOut[20];
test("abc.def", textOut);
printf("%s\n", textOut);
}
The console output with -O2 is "ABC def". Without optimization I get "ABC DEF" like expected. Compiler version 7.2.x an earlier seem not to be affected.
Compiler options used: -mv64+ -g -O2
Ralf