Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
usage of size_t
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Tim Rentsch, post: 4037352"] It has to work only for programs with defined behavior. Consider an implementation with SIZE_MAX == 65535, and supplying an array definition char too_big[ 100000 ] = {0}; to that implementation. This array definition is legal syntax and contains no constraint violations -- right? Hence it may be accepted, either because it's legal or because the implementation has chosen to define an extension for the undefined behavior. If it's undefined behavior we're already home free, so let's suppose for a moment it isn't (ie assume temporarily the declaration is legal). In that case 'sizeof too_big' would yield a value that is outside the range of what size_t can represent, which is an exceptional condition, which is undefined behavior. Hence the implementation can allow such a declaration, yet size_t cannot hold a value large enough to index it. If you disagree with any of the above, would you be so kind as to supply appropriate section citations or references? Unless a program contains a syntax error or constrain violation, it may be accepted without complaint by a conforming implmentation. Since any program with an array of 100000 bytes is never strictly conforming, no required diagnostics plus undefined behavior means the implementation is free to do whatever it wants. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
usage of size_t
Top