Thread: Another question about dynamic allocation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by grumpy View Post
    No it is not.

    The standard requires that the effect of assigning a pointer to zero is the same as assigning it to the NULL pointer.

    There is no requirement that the NULL pointer has a zero value, nor that it is represented with "all bits zero", and there never has been.
    Yes it is. When I mentioned NULL (all caps) here, I'm referring to the null pointer constant.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Subsonics View Post
    Yes it is. When I mentioned NULL (all caps) here, I'm referring to the null pointer constant.
    I knew what you were referring to. You are still mistaken.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by grumpy View Post
    I knew what you were referring to. You are still mistaken.
    Lets first establish what it is you are disagreeing with. "No it is not" subtle or "no it is not" required to be 0. Because there is nothing in post # 31 that I disagree with.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Subsonics View Post
    Lets first establish what it is you are disagreeing with. "No it is not" subtle or "no it is not" required to be 0. Because there is nothing in post # 31 that I disagree with.
    I disagree with your claim that a null pointer constant must have a value of zero.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by grumpy View Post
    I disagree with your claim that a null pointer constant must have a value of zero.
    Well the way it is expressed in the standard:

    An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.
    Does leave open for the possibility of other integer constant expressions (any integer constant expression in fact) to also be called a null pointer constant. But do you really think that is the intended meaning? The consequence being that any integer constant expression is called the null pointer constant.

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Subsonics View Post
    But do you really think that is the intended meaning?
    Yes, having worked with an embedded system, and development environment for that embedded system, where that meaning was exactly the case.

    The standard specifically allows freedoms for implementations (i.e. compilers and host environments). In fact, the standard goes so far as to say that anything it does not specifically define is undefined (or words to that effect). If something is undefined, any interpretation that may occur in an implementation is correct.

    The fact it is possible to detect - as you pointed out - that the wording does leave open the possibility, means it is permitted.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about dynamic memory allocation
    By dayanike in forum C Programming
    Replies: 2
    Last Post: 12-11-2012, 08:35 AM
  2. Dynamic Memory Allocation Question
    By somniferium in forum C Programming
    Replies: 6
    Last Post: 10-12-2012, 07:51 PM
  3. A possibly foolish question about dynamic allocation.
    By manasij7479 in forum C++ Programming
    Replies: 4
    Last Post: 08-24-2011, 06:09 PM
  4. Dynamic Memory Allocation Question
    By Piknosh in forum C++ Programming
    Replies: 1
    Last Post: 04-14-2004, 01:55 PM
  5. dynamic allocation question
    By vale in forum C++ Programming
    Replies: 1
    Last Post: 08-26-2001, 04:23 PM