Thread: undefined behaviour.

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    385

    undefined behaviour.

    Could the values of an undefined behaviour be predicted somehow?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    No, but in practice, it depends, since a particular compiler may be known to do something for certain cases that result in undefined behaviour.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Plus the little problem that if something is undefined, it may work perfectly on one compiler but fall flat on it's face on another...
    A better name might be "unpredictable behaviour"...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Could the values of an undefined behaviour be predicted somehow?
    What did you have in mind - tea leaves, crystal ball, tarot cards, chicken entrails....

    It's a pointless excercise; whatever it is you think you "know" about the undefined behavior is immediately invalidated with the next edit or the next compile.

    Just look at how much "fun" there is to be had, even with simple programs. Using visual studio would really keep you on your toes!

    Here's another term for it.
    Cargo cult programming - Wikipedia, the free encyclopedia
    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. Does the following code show undefined behaviour ?
    By manasij7479 in forum C++ Programming
    Replies: 32
    Last Post: 10-15-2011, 11:44 AM
  2. Undefined behaviour telnet
    By stevesmithx in forum Tech Board
    Replies: 0
    Last Post: 04-22-2008, 01:41 AM
  3. bit shifting...undefined behaviour?
    By Sebastiani in forum C++ Programming
    Replies: 15
    Last Post: 11-07-2007, 02:11 PM
  4. Is this undefined behaviour?
    By caduardo21 in forum C Programming
    Replies: 4
    Last Post: 01-15-2006, 12:55 PM