compiler bug or brain bug?

This is a discussion on compiler bug or brain bug? within the C++ Programming forums, part of the General Programming Boards category; Ok my compiler gives me a warning "bool roof() will always evaluate as true" Code: bool roof() { if((xxx+20) >= ...

  1. #1
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407

    compiler bug or brain bug?

    Ok my compiler gives me a warning "bool roof() will always evaluate as true"

    Code:
    bool roof()
    {
         if((xxx+20) >= 182 && xxx <= 222 && (yyy-200) <= 301)
         {
           yyy=302;
           drawlvla();
           return true;
         }
         else
           return false;
    }
    I don't understand this if xxx = 0; then it should return false. Because it would not be greater than or equal to 182. I understand if I used or statements this would evaluate as true since xxx would always be less than 222 or greater than 182. I have the newest version of dev c++ is this a compiler bug, or is my brain bugged? Thank you for your time.

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    OK sorry the moment after I post I figure out the answer. When recalling the bool function I forgot to use () if(!roof) rather than if(!roof()) I should have waited 10 more minutes before posting.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,403
    Post the smallest and simplest compilable program that demonstrates the warning.

    EDIT:
    Ah.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    C++11 User Tux0r's Avatar
    Join Date
    Nov 2008
    Location
    Sweden
    Posts
    135
    Turn up your warnings and those time crunching problems will disappear like magic!

  5. #5
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    I'm sorry tuxor what do you mean by turn up your warnings?

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Turn up your warnings and those time crunching problems will disappear like magic!
    Sounds like warning were already enabled.
    Ok my compiler gives me a warning "bool roof() will always evaluate as true"

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Well what types are xxx and yyy

    I seriously doubt that you really have variables called xxx and yyy, and that you've paraphrased your problem into something which is not the same.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Quote Originally Posted by Salem View Post
    Well what types are xxx and yyy

    I seriously doubt that you really have variables called xxx and yyy, and that you've paraphrased your problem into something which is not the same.
    He already solved the problem...

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Hmpf
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  10. #10
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    Yea I'm sorry I wish there was I way I could delete the post to not waste people's time.

  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,422
    Your experiences will help others with the same problem. Hopefully.
    Don't worry.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. lcc win32 compiler download problems
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-01-2004, 07:39 PM
  2. OpenScript2.0 Compiler
    By jverkoey in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2003, 12:52 PM
  3. Compiler or OS bug??
    By Frantic in forum C++ Programming
    Replies: 6
    Last Post: 05-20-2003, 11:17 PM
  4. compiler bug ?
    By Spectrum48k in forum C++ Programming
    Replies: 5
    Last Post: 02-25-2003, 08:39 PM
  5. Special Compiler for win app's
    By Unregistered in forum Windows Programming
    Replies: 19
    Last Post: 04-26-2002, 03:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21