Thread: int = double. No warning from GCC?

  1. #16
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Well, I only use double and int though, but I suppose it means the double. Is the actual number too long for double (don't remember ranges)?

  2. #17
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    No it is not.

  3. #18
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    It is with 32-bit longs, as in 32-bit systems. According to the rules of the standard, the compiler has to see if it fits into a int, and if not, try a long. If that also doesn't fit, the behaviour is, I believe, undefined. Or perhaps implementation-defined. The point is, since some platforms GCC compiles for have larger longs than ints, it really tries them in order - and when it fails, it reports that the literal won't fit into a long, since that's the last thing it tried.

    I'm still confused as to why your GCC doesn't give any warnings.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. functions and passing data
    By redmondtab in forum C Programming
    Replies: 41
    Last Post: 09-21-2006, 12:04 PM
  3. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  5. A Simple (?) Problem
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 10-12-2001, 04:28 AM