Thread: Decreasing addresses

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    589

    Decreasing addresses

    What does it mean when a compiler says to allocate memory for variables at decreasing addresses?

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Please paste the exact message, error numbers and all.
    Jason Deckard

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    ... and if it's not obvious from that info, tell us what compiler/OS you are using.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    Well actually it is not a compiler error it is a question on a test I been taking. It shows a bit of code that have a fence post error on an array and ask what would happen if that piece of code is compiled and runed with a compiler that allocates memory for variables at decreasing addresses.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Since all variables are independent entities, there is no way to guarantee that any one variable will lie immediately before or after any other (even if you think you know whether its allocated up or down)

    Given
    int i, j;

    Knowing &i tells you nothing about what &j will be.

    For instance, you dont know
    - which order the compiler allocates them in
    - how much padding there might be between them

    So predicting with any certainty what would happen with a fence post error is a pointless exercise.

  6. #6
    Unregistered
    Guest
    Originally posted by Salem

    Given
    int i, j;

    Knowing &i tells you nothing about what &j will be.
    Does this go for arrays to?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > Does this go for arrays to?

    &arr[i] and &arr[j] can be compared - but this is only guarateed when both are within the bounds of the same array.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Numeric addresses for computers
    By great in forum C Programming
    Replies: 4
    Last Post: 08-23-2010, 11:53 AM
  2. Addresses and extracting the value stored at an address
    By donoe_85 in forum C Programming
    Replies: 4
    Last Post: 04-08-2009, 03:38 AM
  3. Addresses and pointers help...
    By GCNDoug in forum C Programming
    Replies: 13
    Last Post: 04-07-2007, 05:37 PM
  4. how can know in memory someone addresses in free list
    By 0000000009 in forum C Programming
    Replies: 8
    Last Post: 10-17-2005, 12:35 AM
  5. ip addresses and ports
    By jrahhali in forum Networking/Device Communication
    Replies: 3
    Last Post: 11-18-2003, 06:06 AM