Thread: Why can't get the right address for char type

  1. #16
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    actually there are some things in c/c++ that make it more insecure than assembly when you think of it even assembly (intel) has bounds checking instruction and c/c++ just do not seem to care enough undefined

  2. #17
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    C++ offers flexibility. If you want bound checking, use vector. It has defined bound-checking behaviour.

    more insecure than assembly when you think of it even assembly (intel) has bounds checking instruction
    That is comparing apples to oranges. Besides, really? I have never come across it when I learned my assembly (but I only learned the basics, that may be why).

    Of course C++ has them. "<" and ">".

  3. #18
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    about < > operators they depend on the knowledge level of user if the user of language is aware of memory bounds being exceeded etc but c/c++ like hll are supposed to provide a safer environment and beside while doing assembly you are cautious before you take every step so having a bounds checking instruction is a plus and not a comparison of apples and oranges beside i agree with STL stuff vectors etc except one thing that is it is still undefined for a vector:
    Code:
    vector<int> myvec(10, 0); 
    myvec[12*1024] = 0xwhocareswhat;
    
    // undefined

  4. #19
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    bound checking is guaranteed if you use .at() to access the vector. If C++ has all these things guaranteed, it would just be another Java (too restrictive for some). For people who know what they are doing, they like choices (eg, using operator[] or .at() to access a vector, depending on whether they want bound checking)

    while doing assembly you are cautious before you take every step
    And people write C++ code while they are drunk?... That would be undefined by the standard =).

    There are low-level stuff written in C++, eg, device drivers or programs to be run on embedded devices, and bound-checking is not free (it has a performance penalty that may not be acceptable on certain conditions).

  5. #20
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    Quote Originally Posted by cyberfish View Post
    bound checking is guaranteed if you use .at() to access the vector. If C++ has all these things guaranteed, it would just be another Java (too restrictive for some). For people who know what they are doing, they like choices (eg, using operator[] or .at() to access a vector, depending on whether they want bound checking)
    i wonder how much penalty it will make if [] has bounds checking it should not be more than the over head of calling a [] function for non standard data types and for int float just use a plain array if you are really writing realtime application besides no matter how efficient the [] has been made while disregarding bounds it will never be used in a pace maker application they will have their own real time critical solutions

    And people write C++ code while they are drunk?... That would be undefined by the standard =).
    they are just relaxed

    There are low-level stuff written in C++, eg, device drivers or programs to be run on embedded devices, and bound-checking is not free (it has a performance penalty that may not be acceptable on certain conditions).
    cheapest mobiles (cell phones) can run java based applications today we have so much processing powers just that c++ has different philosophy undefined

  6. #21
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    cheapest mobiles (cell phones) can run java based applications today we have so much processing powers just that c++ has different philosophy undefined
    True, they have different philosophies. Java thinks it knows better than the programmer (hence forced bound-checking and forced garbage collection and such), whereas C++ gives programmers choices (optional bound-checking via vector, and optional garbage collection using third party libraries). Therefore, I think Java is a better educational language (where people don't know what they are doing), and C++ is a better practical language (where people know what they are doing).

  7. #22
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    i wonder how much penalty it will make if [] has bounds checking it should not be more than the over head of calling a [] function for non standard data types
    The overhead of vector's [] is exactly zero. The overhead of bounds checking is huge.

    And please use some punctuation and capital letters. Your posts are borderline unreadable.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by (::) View Post
    i wonder how much penalty it will make if [] has bounds checking it should not be more than the over head of calling a [] function for non standard data types and for int float just use a plain array if you are really writing realtime application besides no matter how efficient the [] has been made while disregarding bounds it will never be used in a pace maker application they will have their own real time critical solutions
    Unreadable... >_<

    cheapest mobiles (cell phones) can run java based applications today we have so much processing powers just that c++ has different philosophy undefined
    So much processing power? I think I would love to disagree.
    How many devices today aren't slow? How much time does it take for your phone to start? How long does it take to start an application?
    How about other devices - such as your DVD, your DVD recorder, etc, etc? They are all SLOW. And gee, I do wonder why.
    Perhaps there isn't as much processing power as we through there was.

    Quote Originally Posted by CornedBee View Post
    And please use some punctuation and capital letters. Your posts are borderline unreadable.
    I do so agree
    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.

  9. #24
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    Quote Originally Posted by Elysia View Post
    Unreadable... >_<
    Sorry i do not know where to put comma and where to put full stop

    So much processing power? I think I would love to disagree.
    How many devices today aren't slow? How much time does it take for your phone to start? How long does it take to start an application?
    How about other devices - such as your DVD, your DVD recorder, etc, etc? They are all SLOW. And gee, I do wonder why.
    Perhaps there isn't as much processing power as we through there was.
    there you have it. your way.

    the folks here are trying to squeeze every single instruction and the program is running slow not because of micro processor but dvd, cd, hard disk and nic and user input and what not.

    I do so agree
    sorry. to both Bee and Elysia. i am a non native english speaker (?) writer. so those of you who are also not native english men and women will find it hard to read. i will use more punctuation words if i learn.

  10. #25
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by (::) View Post
    windows mac and linux have protected memory you are working on dos still?
    As someone pointed out, there are systems that are not always able to provide you with memory protection since you might technically own all memory.

    And you still missed the point where I said you could still own the memory you accidentally access. Even on Windows, I can corrupt my program's variables by writing past the end of an array and the program could appear to run properly.

    Quote Originally Posted by (::) View Post
    it is for their convenience not ours that they used undefined instead of taking time to define some useful behavior.
    You're displaying horrible ignorance here, in addition to mixing up the responsibilities of the hardware, software, and languages.

    Language standards like those for C and C++ left many things undefined so as not to restrict the language for the type of hardware and OS that it may be used in conjunction with. In other words, if C++ demands bounds checking, but the hardware is not capable of it, or the OS doesn't take advantage of such ability in the hardware, then by nature C++ functionality is broken on this particular system.

    And for that matter, why do you need a system to check boundaries in this manner to be guarenteed as part of the language? You already know that for all intents and purposes, if you access memory out of bounds, that means you messed up as a programmer, and furthermore, your program is not correct. This is why it is left as being undefined. This way, various systems that have the ability to provided these features can provide it, while those that can't can still support C++.

    There is a lot more to consider than just complaining about bounds checking not being inherent in C++. You could always try to use some sort of class of a data structure that will protect you from yourself, but for pure arrays, this is something beyond what C++ was technically designed for.

  11. #26
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by (::) View Post
    Sorry i do not know where to put comma and where to put full stop
    Quote Originally Posted by (::) View Post
    sorry. to both Bee and Elysia. i am a non native english speaker (?) writer. so those of you who are also not native english men and women will find it hard to read. i will use more punctuation words if i learn.
    Every language has grammar rules. Every language (except for some like Japanese or Chinese), have punctuation, commas, and so on. They are your friend. Use them.
    Punctuation is very important. When a sentence ends, use it.

    Quote Originally Posted by (::) View Post
    the folks here are trying to squeeze every single instruction
    Maybe. Maybe not.
    But I don't like too much processing power being wasted on bloated applications.

    Quote Originally Posted by (::) View Post
    and the program is running slow not because of micro processor but dvd, cd, hard disk and nic and user input and what not.
    Are you sure? Is that why it takes forever to start something or start a program?
    It's because of the slow processor. And therefore, we shouldn't use Java on those platforms. We should use C/C++ for greatest potential speed.
    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.

  12. #27
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    first of all. well said my friend.
    Quote Originally Posted by MacGyver View Post
    As someone pointed out, there are systems that are not always able to provide you with memory protection since you might technically own all memory.
    dunno if they have STL.
    i bet they do not.
    so a moooot point.
    no excuse for keeping [] of vector unsafe.

    And you still missed the point where I said you could still own the memory you accidentally access. Even on Windows, I can corrupt my program's variables by writing past the end of an array and the program could appear to run properly.
    i can see that. thanks for reminding.


    You're displaying horrible ignorance here, in addition to mixing up the responsibilities of the hardware, software, and languages.
    just expecting a little sense of common sense. nothing much.

    Language standards like those for C and C++ left many things undefined so as not to restrict the language for the type of hardware and OS that it may be used in conjunction with. In other words, if C++ demands bounds checking, but the hardware is not capable of it, or the OS doesn't take advantage of such ability in the hardware, then by nature C++ functionality is broken on this particular system.

    And for that matter, why do you need a system to check boundaries in this manner to be guarenteed as part of the language? You already know that for all intents and purposes, if you access memory out of bounds, that means you messed up as a programmer, and furthermore, your program is not correct. This is why it is left as being undefined. This way, various systems that have the ability to provided these features can provide it, while those that can't can still support C++.

    There is a lot more to consider than just complaining about bounds checking not being inherent in C++. You could always try to use some sort of class of a data structure that will protect you from yourself, but for pure arrays, this is something beyond what C++ was technically designed for.
    that is. in short. pain of using languages that get compiled to native binary.

  13. #28
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by (::) View Post
    that is. in short. pain of using languages that get compiled to native binary.
    That made little or no sense.
    And you know, you just have to stay clear of undefined behaviour and you'll have no trouble with C/C++.
    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.

  14. #29
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    Quote Originally Posted by Elysia View Post
    That made little or no sense.
    And you know, you just have to stay clear of undefined behaviour and you'll have no trouble with C/C++.
    in detail:
    such languages have to be concerned with platform differences +plus+ there is always uncertainty. so the undefined behavior. if you wrote your own vm like java you would control every part of it. that is what i meant.

  15. #30
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    I don't get the Java/C++ discussion. For some applications, in particular the scientific computing (image processing, numerical analysis), Java just is not fast enough (let's not speak about programming techniques or the language itself). But graphical user interfaces etc I would never program in C++ but always in java.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Conversion of pointers to functions
    By hzmonte in forum C Programming
    Replies: 0
    Last Post: 01-20-2009, 01:56 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM