Thread: initialization in multi dimensional arrays

  1. #31
    Registered User
    Join Date
    Jan 2014
    Posts
    45
    6.3.2.3p7 considers it relevant.

  2. #32
    Registered User
    Join Date
    Mar 2012
    Location
    the c - side
    Posts
    373
    Quote Originally Posted by phantomotap View Post
    That all said, I consider this situation to be the exact same as the "struct hack": the official interpretation is "undefined behavior" but with so readily available, established semantics that not using it on principal of standard would be silly. What is guaranteed makes any other implementation unreasonable/impractical.


    Soma
    I recently pointed out that overflow in a signed integer is defined by the standard as "undefined behaviour".

    On reflection I'm wondering if there is any compiler that does not handle the overflow in the manner that would be logically/properly expected.

    And thus a pedantic following of the standard in this case might be to deprive oneself of a useful technique?

  3. #33
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    On reflection I'm wondering if there is any compiler that does not handle the overflow in the manner that would be logically/properly expected.
    O_o

    Virtually all compilers handle the overflow in a manner that would be logically unexpected.

    I can already see some people yelling "What!?", but before you post allow me to explain.

    Virtually all compilers have optimizations related to signed integer overflow; depending on compiler flags (command line arguments), pagrams, and similar compilers do very different things with signed integer overflow.

    "CLANG", "Intel", "GCC", and "Microsoft Visual C++" all have modes which will result in broken code if you've implemented almost any form of branching related to signed integer overflow.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  4. #34
    Registered User
    Join Date
    Mar 2012
    Location
    the c - side
    Posts
    373
    Saved from the dark side.

  5. #35
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by zyxwvuts View Post
    Actually, I thought my username was pronounced the same way you would pronounce "abcdefgh" but whatever creative pronounciation you can come up with should work.
    ab-see-deaf-gnu?

  6. #36
    Registered User
    Join Date
    Jan 2014
    Posts
    45
    More like Z. Y. X. W. V. U. T. S. But sure!

  7. #37
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    So this topic makes me want to assert, arrays are flat, right? Like, they're all just 1D arrays with row/column-major indexing, right? C defaults to row, Fortan defaults to column, etc.

  8. #38
    Registered User
    Join Date
    Jan 2014
    Posts
    45
    With regard to the object representation, int[5][2] and int[5 * 2] are identical. However, the type system considers an int[5][2] incompatible with an int[5 * 2], so in that regard they are unique from one another. It is my opinion that staying within the strict, predictable type system is invariably the smarter choice when faced with the option.

  9. #39
    Registered User
    Join Date
    Mar 2012
    Location
    the c - side
    Posts
    373
    Back to the important stuff.

    While on the subject of pronounciation - if I split my username into its 2 syllables:

    Gem - the g is pronounced like the hard g in get.

    Era - is pronounced like era but the e is actually a soft a as in "hair".

    The name is, of course, derived from the Ancient Atlantean for "exceptionally wonderful person".

  10. #40
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Ho -- Hoe
    Dor -- Door

    HODOR

    Alternatively you may pronounce my name like HOLD-OR or HOLD-ER and I will still respond.
    Last edited by Hodor; 03-17-2014 at 06:46 PM.

  11. #41
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I will still respond.
    O_o

    Of course, you will respond only with "HODOR, hodor, HoDoR!" in any event.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  12. #42
    Registered User
    Join Date
    Mar 2012
    Location
    the c - side
    Posts
    373
    Quote Originally Posted by Hodor View Post
    Ho -- Hoe
    Dor -- Door

    HODOR

    Alternatively you may pronounce my name like HOLD-OR or HOLD-ER and I will still respond.
    Technically I was being a bit forgiving in my own pronounciation.

    Pedantically speaking it should actually be Ghem rather than Gem where the 'h' stands for a subtle gutural inflexion.

    But who does gutural these days?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi-dimensional arrays using variables
    By Know_Your_Role in forum C++ Programming
    Replies: 13
    Last Post: 12-10-2009, 12:32 PM
  2. multi-dimensional arrays
    By shuo in forum C++ Programming
    Replies: 7
    Last Post: 06-17-2008, 10:22 PM
  3. multi-dimensional arrays
    By maple23 in forum C Programming
    Replies: 4
    Last Post: 05-31-2008, 01:58 AM
  4. Multi-dimensional Arrays
    By thinhare in forum C Programming
    Replies: 9
    Last Post: 12-20-2004, 09:21 PM
  5. multi-dimensional arrays
    By abrege in forum C++ Programming
    Replies: 3
    Last Post: 02-05-2003, 05:09 PM

Tags for this Thread