Thread: Strange side effects?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    245

    Question Strange side effects?

    I'm using a compiler that is a lot more strict on the C language than normal (it's meant to help create less bugs in the code).

    One thing I'm confused at is that it complains about the following line of code:

    if ((timer == 0) && ((status & 0x100) == modval))

    with:

    Error: the right hand operand of an && or || operator should not contain side effects

    So, can anyone see the side effect it's complaining about? As I certainly can't. Also, why is it specifc about the right hand side?

    If I remove the "== modval" on the right hand side, I get the following additional error:

    Error: this bitwise operation is in a boolean context

    Which is understandable, as it doesn't evaluate to a proper boolean result, but rather assumes that true is anything apart from zero.

    Still doesn't explain why it thinks "status & 0x100" gives a side effect tho'

    EDIT: 'status' is a volatile. That explains it. Why only the right hand side though?
    Last edited by _Elixia_; 08-15-2005 at 02:58 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strange error int
    By faluiretoread in forum C++ Programming
    Replies: 10
    Last Post: 11-15-2008, 05:51 PM
  2. OpenGL example cube is black, white, grey only
    By edwardtisdale in forum Windows Programming
    Replies: 7
    Last Post: 09-22-2007, 02:37 PM
  3. Strange results using dnsapi and windns
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-13-2005, 10:21 AM
  4. Low latency sound effects
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 12-21-2004, 01:58 AM
  5. Side effects
    By Eibro in forum C++ Programming
    Replies: 4
    Last Post: 07-23-2003, 06:26 AM