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

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
  • The statement in question that started me down this path is:
    *((Byte *)line.pointer)=active_thread;
    Hopefully, I didn't type in any new syntax errors.
    Anyway, the pointer element is declared as
    void code *pointer;
    so yeah it tries to store the value of active_thread into a code location. However, my question still stands. Why should the compiler simply throw it out without flagging me? Even if the process is involved, errors should be detected and reported. Seems like a bug in the compiler to me.

Reply
  • The statement in question that started me down this path is:
    *((Byte *)line.pointer)=active_thread;
    Hopefully, I didn't type in any new syntax errors.
    Anyway, the pointer element is declared as
    void code *pointer;
    so yeah it tries to store the value of active_thread into a code location. However, my question still stands. Why should the compiler simply throw it out without flagging me? Even if the process is involved, errors should be detected and reported. Seems like a bug in the compiler to me.

Children
  • Your syntax is fine, so the compiler's syntax checking must give no errors.

    The error lies only in the fact that you have tried to write to a non-writable memory area; therefore, if the optimiser has removed that attempted write, there is nothing wrong with your code!