This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unable to run code in optimization level O1, O2 and O3 in DS-5

 

Hi all,

 

I am able to run code in optimization level - O0 in DS-5 and outputs also matched with reference outputs, but the same code is not working in other optimization levels - O1, O2 and O3 in DS-5, it is simply exiting from program.

typedef short Word16;

typedef struct student

{

 

       Word16  x;
       Word16  y;

}stu;

void inputs_read( stu *st_fx)

{

          st_fx->x= 0;

          st_fx->y= -1;

}

This code is not working in DS-5.  when i am trying to run, at this point program execution stopped in DS-5.

I tried debugging the code in -O1, -O2 ,I found it is not able to find some structure variables with data type short int , other variables from the same structure with same data types are working fine. I didn't understand the reason.

I added a printf() statement in between these two structure variables , with this code is working fine. But i am not getting whether the issue is related to structure variables or alignment or with other.

void inputs_read( stu *st_fx)

{

          st_fx->x= 0;

          printf("%d\n", st_fx->x);

          st_fx->y= -1;

}

with this printf() statement code is working fine.  

Can anyone please guide me on this. I blocked at this point, please help me on this.

 

Thanks in advance,

Divya.

Parents
  • The compiler would have automatically inlined that function without the printf when optimizing, so the bug probably has something to do with optimizing the function that calls it when those lines are inlined. I'm afraid I can't guess from what might be happening otherwise.

Reply
  • The compiler would have automatically inlined that function without the printf when optimizing, so the bug probably has something to do with optimizing the function that calls it when those lines are inlined. I'm afraid I can't guess from what might be happening otherwise.

Children