error messages versus opt level

I have noticed that I get error messages or I don't sometimes depending on optimization level. For example, I had a statement that tried to store a value into code space and at opt level zero, I got an error saying that it couldn't convert the lvalue. I understood this. However, at opt level 8, I got no error and in fact the 'optimizer' simply left out the offending line. Why should it do this? If it is an error, it should report it and not throw the code away.

Parents
  • We tried to duplicate your problem, but no matter which optimization level or compiler version we are using we are getting a correct error message. You your case must be different from ours. How can we duplicate it?

    Our test file is as follows:

    stmt level    source
    
       1          struct  {
       2            unsigned char      v;
       3            unsigned char code *ptr;
       4          } s;
       5          
       6          void main (unsigned char t)  {
       7   1        *((unsigned char * )s.ptr) = t;
       8   1      }
    *** ERROR C183 IN LINE 7 OF Y.C: unmodifiable lvalue
    

Reply
  • We tried to duplicate your problem, but no matter which optimization level or compiler version we are using we are getting a correct error message. You your case must be different from ours. How can we duplicate it?

    Our test file is as follows:

    stmt level    source
    
       1          struct  {
       2            unsigned char      v;
       3            unsigned char code *ptr;
       4          } s;
       5          
       6          void main (unsigned char t)  {
       7   1        *((unsigned char * )s.ptr) = t;
       8   1      }
    *** ERROR C183 IN LINE 7 OF Y.C: unmodifiable lvalue
    

Children
More questions in this forum