reliably checking for overflow before addition?

This is a discussion on reliably checking for overflow before addition? within the C++ Programming forums, part of the General Programming Boards category; Then hopefully we'll be able to get limited evaluation at compile time some time in the future, as they define ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,434
    Then hopefully we'll be able to get limited evaluation at compile time some time in the future, as they define what limited is. Hopefully.
    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.

  2. #17
    Registered User
    Join Date
    Jun 2005
    Posts
    6,203
    Quote Originally Posted by Elysia View Post
    The first I can understand (maybe), but the second...? Why the heavy restrictions? To make it easier for compilers?
    So long as the function contains code that can be determined at compile time, it shouldn't be a problem, even if calls it recursively or return multiple things.
    Making it easier for compiler (or compiler vendors) is one reason. The other common reason is that less restrictions usually mean a lot more possible meanings to be properly specified in the standard (which is a lot of work, as interactions with other language features have to be properly analysed and/or specified). Easier in the first instance (particularly with a large language like C++) to specify something in a restricted manner, and only relax restrictions if there is a real world need to do so.

  3. #18
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Easier in the first instance (particularly with a large language like C++) to specify something in a restricted manner, and only relax restrictions if there is a real world need to do so.
    Yes, this is very significant also. Remember, you can never back something out of a standard, only add to it, if you want to keep backward compatibility.
    The only exception I know of is the auto keyword, whose old meaning will be removed completely. That's safe because absolutely nobody used that keyword, and even if someone did, it's completely redundant anyway.
    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

  4. #19
    Registered User
    Join Date
    Jun 2005
    Posts
    6,203
    Quote Originally Posted by CornedBee View Post
    Yes, this is very significant also. Remember, you can never back something out of a standard, only add to it, if you want to keep backward compatibility.
    You're right, but it's worth noting there is a defined mechanism for backing things out of the standard: deprecation is essentially flagging a feature for removal from a future version of the standard. Of course, actually removing a previously deprecated feature will break backward compatibility, so it will be interesting to see if any deprecated features in the language ever do disappear in a future version of a standard for C or C++ and - if they do - how many vendors will remove them.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Overflow and range checking for mul/div
    By Elysia in forum C++ Programming
    Replies: 28
    Last Post: 06-06-2008, 02:09 PM
  3. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  4. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 06:57 PM
  5. Problems about gcc installation
    By kevin_cat in forum Linux Programming
    Replies: 4
    Last Post: 08-09-2005, 09:05 AM

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