Thread: undefined and implementation specific constructs

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    450

    undefined and implementation specific constructs

    As an exercise in Barjne Strousups book he asks to make a list of five constructs which are undefined in C++ and five constructs which are implementation specific.

    I couldn't come up with five of each, but thought it would be a good resource if you could list any examples you can think of.

    Here is what I came up with from the text.
    Undfined:
    1. Overflow/Underflow
    incrementing/decrementing past the max size of the argument type.

    2. Division by Zero
    3. subexpression evaluation
    int i=f(1)+g(2);// cannot assume left to right evaluation.

    The only one I could come up with that is implementation dependant is:
    The definition of NULL;

    Feel free to add your own

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Go read the language standard - there are lots

    These are implementation defined.

    The number of bits in a byte (CHAR_BIT)

    The sign of the result of % on negative integers

    The size of all non-char data types (eg sizeof(int) is 1, 2, 4, 8 depending on your machine)

    Everything about bit-fields is implementation specific

    The effect of shift left/right on negative integers

    > 3. subexpression evaluation
    That's more unspecified than undefined
    http://www.eskimo.com/~scs/C-faq/q11.33.html

    Undefined means absolutely anything, like
    array[i++] = i;
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. including header files and implementation
    By steve1_rm in forum C Programming
    Replies: 4
    Last Post: 01-12-2009, 08:59 PM
  2. Implementation of a template class functions
    By 39ster in forum C++ Programming
    Replies: 3
    Last Post: 01-08-2008, 03:36 AM
  3. implementation file
    By bejiz in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2005, 01:59 AM
  4. Undefined reference problem
    By Speedkill in forum C++ Programming
    Replies: 3
    Last Post: 09-30-2003, 01:42 PM
  5. undefined vs. unspecified (C++ standard)
    By Sang-drax in forum C++ Programming
    Replies: 7
    Last Post: 11-12-2002, 11:51 AM