Pelles C forum

Pelles C => Bug reports => Topic started by: Franzki on March 13, 2011, 02:06:03 AM

Title: string value not visible in debugger (compiler optimization)
Post by: Franzki on March 13, 2011, 02:06:03 AM
See the attached code sample.

In the function "clear_string" I can't watch the value of the string "text" when I switch off optimization.
Flags are: -Tx86-coff -Zi -Ob1 -fp:precise -W1 -Gd

I'm always in doubt what optimization I should use for debugging purposes... I thought all variables should be visible with optimization turned off.

???




Code: [Select]
#include <string.h>
#include <stdio.h>

void clear_string(char * text)
{
strcpy(text,"");
printf("string cleared!\n");
}


int main(void)
{
char text[100];

strcpy(text,"This is a test");
printf("old string: %s\n",text);
clear_string(text);
printf("new string: %s\n",text);
return(0);
}
Title: Re: string value not visible in debugger (compiler optimization)
Post by: AlexN on March 14, 2011, 08:27:17 AM
I'm always in doubt what optimization I should use for debugging purposes... I thought all variables should be visible with optimization turned off.
Usually you should debug a program without optmization. In your case I think it is an error in the debugger, so that it don't see the variable text.