Thread: Multidimensional Array Niggles!!!

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by tabstop View Post
    What extra security measures are these? Either you ran a test that exposed the error, in which case you can debug (if you chose debug) or you can maybe debug (if you chose exceptions); or you didn't run a test that exposed the error, in which case debug vs. exceptions don't matter.
    It does matter, because it stops undefined behavior in case you miss it!

    Exceptions for user errors?!
    What does that mean?

    I mean, come on, it's such a simple change. Change index operator to at(). You shouldn't be using C-style arrays anyway, since we have std::array, and yes, it has at().
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Elysia View Post
    It does matter, because it stops undefined behavior in case you miss it!
    I'm sure you're talking about this particular bit of undefined behavior.

    Quote Originally Posted by Elysia
    I mean, come on, it's such a simple change. Change index operator to at(). You shouldn't be using C-style arrays anyway, since we have std::array, and yes, it has at().
    You'd like it to be that simple. Of course, I feel like I haven't talked with you at all since you're comfortable with this sort of post, still. I think recently you should have read reasons why exceptions aren't as easy or as reasonable for debugging as you say they are.

    To your point about why we can't catching exceptions, I misspoke. I meant a no-throw guarantee not the strong one. Even so, I directly asked what if the code shouldn't throw exceptions, which you didn't answer as if I was making something up. But really to me the no-throw guarantee existing makes me shun exceptions as a debugging tool. I mean, I'd rather meet my exception safety guarantee than break it to "prevent undefined behavior."

    ETA: This also bugged me a lot:
    OK, to be honest, if you have catch blocks, it might be a little harder to catch the problems, but debuggers can be configured and code can be disabled.
    Who cares. As far as I know that has nothing to do with fixing bugs in released code, which I think is your primary reason for liking exceptions so much. Presumably, (you brought this up as an argument but) there is some code path you haven't tested and you want to "disable code" to help you discover errors. Does not compute.

    Danger Will Robinson, danger!
    Last edited by whiteflags; 07-21-2011 at 03:56 AM.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by whiteflags View Post
    You'd like it to be that simple. Of course, I feel like I haven't talked with you at all since you're comfortable with this sort of post, still. I think recently you should have read reasons why exceptions aren't as easy or as reasonable for debugging as you say they are.
    Nothing that has changed my mind so far.

    To your point about why we can't catching exceptions, I misspoke. I meant a no-throw guarantee not the strong one. Even so, I directly asked what if the code shouldn't throw exceptions, which you didn't answer as if I was making something up. But really to me the no-throw guarantee existing makes me shun exceptions as a debugging tool. I mean, I'd rather meet my exception safety guarantee than break it to "prevent undefined behavior."
    I couldn't answer it because it made no sense.
    But I agree that I would meet exception safety than break it to prevent undefined behavior.
    However, that just means that the function needs to eat any exceptions it throws. So using at() is still fine so long as you don't let it propagate.
    If the function must be able to throw exception such as those from at(), then your design is broken if the function has a no-throw guarantee.

    Who cares. As far as I know that has nothing to do with fixing bugs in released code, which I think is your primary reason for liking exceptions so much. Presumably, (you brought this up as an argument but) there is some code path you haven't tested and you want to "disable code" to help you discover errors. Does not compute.
    But it is also a tool for finding out-of-bounds access more easily, too, since an out-of-bound index can easily be a memory location where another variable is located, which could mean a lot of false positives if you try to monitor for writes/reads there.
    But it does not mean you can be lazy with your testing and debugging because you have safeguards in place. You should always properly test your code as much as you can.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    But it is also a tool for finding out-of-bounds access more easily, too, since an out-of-bound index can easily be a memory location where another variable is located, which could mean a lot of false positives if you try to monitor for writes/reads there.
    I'd be too busy tracing the execution of the program to find out which object actually threw the exception under what conditions to decipher what you said. Also, after I did, I would probably fix the error as long as we didn't release already. If we did release, it would probably just go into the next build. And that's the best case scenario, me finding an error by myself. I guess the exception will help me if I was doing something about a bug in a report, since whatever the user did probably elicited the error. Maybe.

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You can disable the catch block for the exceptions at() throws, then your debugger will catch the exception, all the time.
    Or you can configure your debugger to catch them no matter what.
    Problem solved.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    If you say so.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with MultiDimensional Array (I think)
    By RommelTJ in forum C Programming
    Replies: 5
    Last Post: 11-25-2009, 02:30 AM
  2. 2d multidimensional array
    By epica in forum C Programming
    Replies: 2
    Last Post: 08-20-2009, 04:43 PM
  3. help with multidimensional array
    By keira in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2008, 11:28 AM
  4. Copy multidimensional array to single array?
    By seepox in forum C Programming
    Replies: 9
    Last Post: 05-08-2006, 11:19 AM
  5. Multidimensional Array
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-17-2001, 06:18 PM